Friday, July 16, 2004

Script-killer comments

This one seems like a no-brainer, but it had several of our best JS experts stumped for a good while, until we saw what was right in front of us all along.

A script for preloading images was failing. The source was similar to this (imagine 20 or more lines of unbroken script):

<script type="text/javascript">
<!-- preload_images ("header1.gif", "header2.gif", "logo.gif");
//-->
</script>

Notice how the first line of script is preceded by an HTML comment delimiter. This prevented the preload_images function from running, as the JS interpreter just skipped over the entire line. For the want of a linebreak, the script was hosed.

This seems to be common when JS is generated from some backend process. The above JavaScript was generated from a server-side application written in C++.

1 Comments:

At 6:24 AM, Blogger HiiFii Webservices said...

I liked you Blog so much,so i also wanted to show you some good resourses on the net.
Learn to earn 90000$/Month
For which you may also see my Personal Website
Here.
and for a Personal Education Career Tools
free Study Database.
This site is for seeing the
Hifi Electronics.
And this is for
World Class Gadgets

 

Post a Comment

<< Home