Page 1 of 1

strange syntax

Posted: Fri Oct 20, 2006 6:28 pm
by Luke
I often find code like this...

Code: Select all

<script	type="text/javascript">
if(ns4)_d.write("<scr"+"ipt type=text/javascript src=../menu/mmenuns4.js><\/scr"+"ipt>");		
  else _d.write("<scr"+"ipt type=text/javascript src=../menu/mmenudom.js><\/scr"+"ipt>"); 
</script>
Why the "<scr" + "ipt" ??

Am I missing something? I don't get it.

Posted: Fri Oct 20, 2006 6:30 pm
by Burrito
because it's being written out with javascript, it's to not confuse the 'real' script tags with the ones being written.

Posted: Sat Oct 21, 2006 5:32 am
by Maugrim_The_Reaper
You can just remove the + and surround your javascript (inside the script tags) with "<![CDATA[" and "]]>". This will tell the browser the contents of CDATA are literal characters not to be interpreted as markup.