|
Posted by Randy Webb on 11/19/07 23:17
Mika said the following on 11/19/2007 6:06 PM:
> "Stevo" <please@spam-me.com> wrote in message
> news:fht3gu$ctk$02$1@news.t-online.com...
>> Mika wrote:
>>>>> Can anyone suggest another way to do this (which doesn't work)?:
>>>>> <!--[if IE]></body><![endif]-->
>>>> Have you tried using document.write("<\/body>"); ?
>>> Apologies, could you put the code in context and in laymen's terms
>>> please? Exactly what should we add to make only IE see a </body> command?
>> I'm not up on using conditional comments, I try to avoid them, but I would
>> imagine this would work (using the conditional comments syntax from your
>> example because I don't know the syntax):
>>
>> <!--[if IE]>
>> <script type="text/javascript">document.write("<\/body>");</script>
>> <![endif]-->
>
> Thanks Stevo, it doesn't seem to work. IE ignores it.
Do you get an alert if you change the document.write to alert? That
would tell you for sure that IE was seeing the code and not just
ignoring the conditional comments.
> Out of interest why does body have a double-slash "\/" before it?
The script engine has every right to close the script block when it
encounters the sequence </ after the opening script tag. The / gets
escaped to break up that sequence. That said, there are no modern UA's
that close it until it reaches </script> but it is an old habit that
dies hard.
> I wonder if there is another way to say "only if you are IE, close the body
> tag here"...
<script type="text/javascript">
/*@cc_on @*/
/*@if (@_jscript_version >= 4)
document.write('<\/body>');
@end @*/
</script>
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Navigation:
[Reply to this message]
|