parseDOM error in Firefox 45.0
I use the folowing code to convert HTML page into DOM object
var parser = new DOMParser(); var htmlPage = '<img id="img1" src="myImage.jpg" /> '; var doc = parser.parseFromString(htmlPage, "text/html");
and then I can use the doc object to access any html component like this
doc.img1
This morning I upgraded my firefox to version 45.0 (latest version), but suddenly the above code stopped working!! and I start to get the error
doc.img1 is undefined
is there anything wrong? or did mozilla changed the way the parse the HTML into DOM... or is it a bug?
John99 modificouno o
Chosen solution
Posted the site compatibility document.
Ler a resposta no contexto 👍 0All Replies (5)
This method of accessing DOM nodes is not recommended. For me it "works" in Firefox 45, however you should use the standard getElement... methods that are available -- these should not have any issues. Also check that your HTML string used is well-formed. For general programming questions, please ask for help on programming sites such as Stack Overflow.
@Qantas94Heavy Thank you for your reply, but I am still in a need to convert HTML text into DOM object... the code above worked well on versions prior to 45.0 I am sure the HTML is well formed with no problems, I have asked the same question on stack over flow, and I am waiting for an answer
http://stackoverflow.com/questions/35.../parsedom-error-in-firefox-45-0
I can confirm the issue. Investigating...
Okay, looks like this was an intentional change. doc.img1
doesn't work in Chrome neither. doc.getElementById('img1')
should always work. I'll write a document on this change.
Chosen Solution
Posted the site compatibility document.