Problem with HTML Parser in IE

后端 未结 9 833
醉梦人生
醉梦人生 2020-12-24 05:56

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 E

相关标签:
9条回答
  • 2020-12-24 06:17

    Like Sergey Kirienko said: use conditional comments. The code below will only be executed by internet explorer. Microsoft has good information on this page.

    <!--[if IE]>
    <script type="text/javascript"> 
     showDialog('¡Aviso Importante!','message','warning',10);
     </script>
    <![endif]-->
    

    If you want a specific version you can test for that too:

    <!--[if lte IE 7]>
        <script type="text/javascript"> 
         showDialog('¡Aviso Importante!','Your are using a too old version of Internet explorer. Please upgrade','warning',10);
        </script>
    <![endif]-->
    
    0 讨论(0)
  • 2020-12-24 06:18

    javascript works very easy with navigator.appName. (see http://de.selfhtml.org/javascript/objekte/navigator.htm) You can create an if-query with this. Very easy, just try it!

    0 讨论(0)
  • 2020-12-24 06:19

    Reading the doc linked by porneL, I found a simple workaround for this problem: Adding a parameter 'defer' to the script, all works fine.

    <script defer=true>
    
    0 讨论(0)
  • 2020-12-24 06:23

    I had this same problem. My issue was that I was calling a Javascript function before the containing div was closed.

    To fix the problem, I call the Javascript function within the jQuery ready event handler:

    $(document).ready(function(){
        some_random_javascript_function();
    });
    
    0 讨论(0)
  • 2020-12-24 06:35

    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.

    0 讨论(0)
  • 2020-12-24 06:35

    Maybe a little late, but this error also pops up if you are using SWFObject and have 2 divs with the same id.

    I had duplicate divs, [with id="flashcontent", thanks to copy&paste].

    Solved by renaming the divs with unique ids.

    0 讨论(0)
提交回复
热议问题