Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

parseDOM error in Firefox 45.0

  • 5 respostas
  • 1 has this problem
  • 7 views
  • Last reply by Kohei

more options

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?

I use the folowing code to convert HTML page into DOM object var parser = new DOMParser(); <nowiki>var htmlPage = '<img id="img1" src="myImage.jpg" /> '; </nowiki> 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

All Replies (5)

more options

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.

more options

@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

more options

I can confirm the issue. Investigating...

more options

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.

more options

Chosen Solution