Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Strange Parser Error

Options
  • 03-09-2003 11:57am
    #1
    Closed Accounts Posts: 156 ✭✭


    I have a page with the following javascript

    if(ie4)
    {
    var myStr1 = "<OBJECT .......";
    var mystr2="</object>";
    document.write(myStr1);
    }
    else
    {
    document.write("<OBJECT .......");
    }


    The browser throws an error if i dont have var mystr2="</object>"; Complainging i cant have one object tag inside another, mystr2 is never used it is just there to get the parser to continue.

    Strange thing is this happens in both IE6 and NS7 - could it be both NS and MS are getting their parsers from someone else. The parser seems to ignore the fact the object tag is inside a javascript block. - I thought it wierd that both browsers would have this bug/feature.


Comments

  • Registered Users Posts: 7,739 ✭✭✭mneylon


    How did you open your javascript declaration?
    If you provide the full code block it would be easier to see what you are doing


  • Closed Accounts Posts: 156 ✭✭JJSolutions


    Nothing much exciting happening outside the above code


    <script language="JavaScript">
    <!--
    function f()
    {
    ... browser check code ....

    if(ie4)
    {
    var myStr1 = "<OBJECT .....";
    var mystr2="</object>";
    document.write(myStr1);
    }
    else
    {
    document.write("<OBJECT .....");
    }
    }
    //-->
    </script>


  • Registered Users Posts: 7,739 ✭✭✭mneylon


    Try setting the mime type and see what happens


  • Closed Accounts Posts: 156 ✭✭JJSolutions


    nope didnt make a difference - i even noticed that if the line

    var mystr2="</object>";

    is commented out it still makes it work but once it is deleted the error occurs

    even

    //</object>

    works - as long as there is a closing object tag it will work.

    Why do you think that the behavior is the same on NS and MS


  • Registered Users Posts: 1,452 ✭✭✭tomED


    It's hard to get an idea of what you are trying to do without an example of the exact code you are using.

    Why not give use exactly what you are doing and we'll try and see whats wrong.

    I have tried to replicate what I think you are saying with my own code and have had no problems.

    But maybe I'm doing something different...


  • Advertisement
  • Closed Accounts Posts: 156 ✭✭JJSolutions


    That is the whole code - I havent got a problem with the code, it is on the jjsolutions.ie homepage if you want to look at it.

    The point i was trying to make was it is strange that both browsers dont pick up that the two object tags are being written dynamically to the page and thinks there is two open object tags inside each other.

    .. and that even commented code will prevent the error from occurring


Advertisement