Advertisements on the D site

Gary Willoughby dev at nomad.so
Mon Dec 9 04:53:55 PST 2013


On Monday, 9 December 2013 at 08:19:49 UTC, Jacob Carlborg wrote:
> Comment starts here, but inside the JavaScript block. I have no 
> idea how browsers handle this:
> <script type="text/javascript"><!--
>
> JavaScript comment starts and ends here:
> /**/google_ad_client = "pub-5628673096434613";
>
> Comment ends here, but inside the JavaScript block and 
> commented out using JavaScript:
> //--></script>

It's an old trick. The comment is a HTML comment to stop browsers 
that don't handle JavaScript from interpreting the JS code as 
HTML. The closing bracket is commented out because the JS 
interpreter fails when reading it. This is from back in the day 
when IE didn't handle JS only VBScript.


More information about the Digitalmars-d mailing list