Click to See Complete Forum and Search --> : Basic question from newbie...


ben456
12-27-2002, 03:06 AM
I don't pretend to understand JS but have used a number of excellent scripts from this site and others.

This will probably sound like a silly question but can someone please tell me what the significance is of the <!-- and //--> comments at the beginning and end of the scripts? They still seem to work without them so what are they for?

Also, can anyone recommend a good online tutorial to learn the basics?

Thanks,
Ben

ShrineDesigns
12-27-2002, 03:21 AM
for older browser that don't support javascript if these "<!--" "//-->" are not put around your code; older browser display the code inside the script tags as plain text "<!--" "//-->" prevent that from happenning

as for online tuts i would like to know also

ben456
12-27-2002, 03:55 AM
Thanks for that, good to know. Do you just need one set around all the JS on the page?

Ben

ShrineDesigns
12-27-2002, 04:07 AM
put the "<!--" "//-->" inside every script element

example:

<script language="JavaScript">
<!--
function myfunc(){
if (document.mytext.value == "hello"){
alert('hello');
}
}
function ....(){
...
}
//-->
</script>

ben456
12-27-2002, 04:11 AM
That's great.

Thanks