I have a question on javascript and dom; The following code should not get three fu: body element in the body? The warning window shows zero This does not work in any browser (not Chrome canaries). Thanks for helping, be a good weekend.
& lt ;! DOCTYPE html public "- // W3C // DTD XHTML 1.0 strict // n" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> & Lt; Html xmlns = "http://www.w3.org/1999/xhtml" xmlns: foo = "http://foo.com" & gt; & Lt; Top & gt; & Lt; Title & gt; Hello and lt; / Title & gt; & Lt; Script type = "text / javascript" & gt; Function bodyLoad () {var extElements = document.getElementsByTagNameNS ('http://foo.com', 'bar'); Warning (extElements.length); } & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body onload = "bodyLoad ();" & Gt; & Lt; Foo: bar & gt; First Foo-Bar & lt; / Foo: Bar & gt; & Lt; Foo: bar & gt; The second foo-bar & lt; / Foo: Bar & gt; & Lt; Foo: bar & gt; The third foo-bar & lt; / Foo: Bar & gt; & Lt; / Body & gt; & Lt; / Html & gt;
You are serving the document The browser with the wrong content type should be treated as XML for nominations, so that you need to use the application / xhtml + xml
or other XML content-type, and Text / html
.
On one hand, your doctor is wrong. If you want to use a DTD, you will need one which contains elements which you are using from foo namespace. If you do not, then get rid of the docepipe - XML documents do not have any effect again on the presentation mode (again, the text / html> document is considered as tag soup, XML No).
Comments
Post a Comment