Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with HTML Parser in IE

I am trying to create a dialog box that will appear only if the browser selected is IE (any version) however I get this error:

Message: HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)

That's all in "Line/Char/Code" 0 so I do not know where is the error. The code I'm using is this:

 <script type="text/javascript">    <!--     if(BrowserDetect.browser.contains("Explorer"))   {          var Nachricht = 'Hemos detectado que está utilizando ' + BrowserDetect.browser + ' ' +   BrowserDetect.version + '. Puede que algunas funciones no estén habilitadas. <p></p> Si desea experimentar todo el potencial del portal, por favor intente desde otro navegador (browser). <p></p>Gracias  showDialog('¡Aviso Importante!',Nachricht,'warning',10);  }   </script> 

I've noticed if I remove the "BrowserDetect.browser" and .version it removes the error, but I need those to check =/...any ideas will be appreciated =).

like image 869
Tsundoku Avatar asked Nov 19 '08 10:11

Tsundoku


People also ask

What is parsing error in HTML?

The parse error in CSS arises when the CSS parser detects something that does not comply with the requirements. Usually, a CSS parser demands CSS be written in a certain way. CSS parser has specific requirements that include: Adding a semicolon at the end of all CSS properties.

How does HTML parser work?

HTML parsing involves tokenization and tree construction. HTML tokens include start and end tags, as well as attribute names and values. If the document is well-formed, parsing it is straightforward and faster. The parser parses tokenized input into the document, building up the document tree.

What does HTML parser mean?

The HTML parser is a structured markup processing tool. It defines a class called HTMLParser, ​which is used to parse HTML files. It comes in handy for web crawling​.


1 Answers

You're modifying document while it's being loaded (when browser hasn't "seen" closing tag for this element) . This causes very tricky situation in the parser and in IE it's not allowed.

IE blog has explanation of this.

The solution is to modify another element that's earlier in the document and has been loaded completely (where browser already saw closing tag for it).


BTW: The string </ is not allowed in <script> element. Use <\/ which is a safe equivalent in JS strings.

like image 173
Kornel Avatar answered Sep 20 '22 14:09

Kornel