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 =).
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.