Page 1 of 1

Escaping javascript

Posted: Sat Jun 30, 2007 4:00 pm
by alex.barylski
Or rather tricking the HTML parser to skip JS code...

Code: Select all

<script>
//<!--
  alert('Now the HTML parser shouldn't choke incase it doesn't understand <script>???');
//-->
</script>
Is this really nessecary? I assume that is what the technique above is doing?

Posted: Sat Jun 30, 2007 4:40 pm
by superdezign
It was used for browsers that couldn't handle JavaScript. They basically no longer exist, so the method is beyond deprecated.

Posted: Sat Jun 30, 2007 6:10 pm
by alex.barylski
superdezign wrote:It was used for browsers that couldn't handle JavaScript. They basically no longer exist, so the method is beyond deprecated.
Thats what I figured...except that with the Mobile devices is that really the case?

Posted: Sat Jun 30, 2007 6:28 pm
by superdezign
Hockey wrote:
superdezign wrote:It was used for browsers that couldn't handle JavaScript. They basically no longer exist, so the method is beyond deprecated.
Thats what I figured...except that with the Mobile devices is that really the case?
They don't run the JavaScript, but they are aware that it exists, so they ignore the <script> tags themselves. The commenting is for browsers that are pre-JavaScript age.