the brilliant logo

Problems with scripts.

Some editors have strange ways of compressing what you 'paste' so that it turns into a very long line. HTML commands will work when they are all in a single line because the < and > characters separate each command. Javascript however is very very picky about where one line ends and the next begins.


Look very carefully at the original script and compare it to what has been pasted into your page.

Sometimes, when the cut and paste code contains comments, the comments get wrapped around the working code which then thinks it's part of the comment and (like all good comments) takes no part in the action. Spot the differences and fix the code :)

Sample script - as shown it works (prints Hello World):

<script language="javascript">
<!--
document.write('Hello World')
// -->
</script>

Same original - does nothing because the real script line has been added to the comment.

<script language="javascript">
<!--document.write('Hello World')// -->
</script>

Same original - gives an error because the script line has been split into two

<script language="javascript">
<!--
document.write
('Hello World')
// -->
</script>

Same original - gives an error because <BR> is not a javascript command (often occurs with webTV).

<script language="javascript"><BR>
<!--<BR>
document.write('Hello World')<BR>
// --><BR>
</script>

Always be very careful pasting javascripts. Make sure you or your editor does not generate these errors.


halfadot.com

CONTACT   |   HOME   |   BACK  |   TOP