Discussions
Categories
Groups
Advertisement
Child Item
Home
Topics
Technology & Internet
Software & Web Development
Design
Strange Parser Error
JJSolutions
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.
Find more posts tagged with
Quick Links
All Categories
Recent Posts
Activity
Unanswered
Groups
Best Of
Advertisement
Advertisement
Comments
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
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>
mneylon
Try setting the mime type and see what happens
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
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...
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