Hi Nidhi,
sorry for being a bit late with my respond.
I did try your suggestion amongst other things.
Here are two other options:
1: Which uses // style javascript comments instead of /* ... */
<script type="text/javascript" language="javascript">
//<![CDATA[
document.write('Hello World!');
//]]>
</script>
I suspect the result is exactly the same as nidhi's suggestion in all browsers
2: Which use of simple html style comments (and a javascript // comment):
<script type="text/javascript" language="javascript">
<!--
document.write('Hello World!');
//-->>
</script>
I've seen this method used and suggested somewhere - and sometimes in combination with CDATA tags, but I don't really understand why it works, and it's probably also a kind of legacy approach to hide javascript from incompatible browsers.
3: The 'catch-all' bulletproof approach
<script type="text/javascript">
<!--//--><![CDATA[//><!--
document.title = "Foo & Bar";
//--><!]]>
</script>
I suppose it'll work. But as the author states:
"Remember that the very concept of sending XHTML to be handled by an HTML engine is essentially a hack and cannot be done flawlessly."
Source:
http://www.webdevout.net/articles/escapi...
For me the first approach did the trick in the major browsers.
Thanks, nidhi