Hi,
Can anyone give instructions, or know where I can find instructions, on creating an external java script file? Plain, precise, non-techy language would be best in my case, but any help at all will be appreciated.
Thanks!
Hi,
Can anyone give instructions, or know where I can find instructions, on creating an external java script file? Plain, precise, non-techy language would be best in my case, but any help at all will be appreciated.
Thanks!
Do you mean write an external javascript from scratch or adapt an existing internal one to be used as an external one? From scratch is easy,
Simply save the above code to a file and name it 'alertdone.js'Code:alert('Done!');
Add this code to the head of your html page:
Adapting an internal script is similar but can get tricky depending upon the script. Many can be adapted simply by removing the '<script>' and '</script>' tags from the code, saving that code to a file and giving that file a name say, 'myscript.js', then putting this in the head or body (depending upon where the script was originally meant to go) of your page:Code:<script src="alertdone.js" type="text/javascript"></script>
Code:<script src="myscript.js" type="text/javascript"></script>
Last edited by jscheuer1; 05-20-2005 at 09:00 PM.
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
It should also be noted that SGML comments (<!-- ... -->), should be removed. So, given:Originally Posted by jscheuer1
onlyCode:<script type="text/javascript"> <!-- Hide from browsers /* Script content */ // --> </script>
should be saved. The SGML comments shouldn't be present anyway, but many old scripts haven't been updated to omit them.Code:/* Script content */
Mike
Bookmarks