March 31, 2008

How do we get JavaScript onto a web page?

You can use several different methods of placing javascript in you pages. You can directly add a script element inside the body of page.
1. For example, to add the "last updated line" to your pages, In your page text, add the following:

blah, blah, blah, blah, blah.



yada, yada, yada.


(Note: the first comment, "<--" hides the content of the script from browsers that don't understand javascript. The "// -->"
finishes the comment. The "//" tells javascript that this is a comment so javascript doesn't try to interpret the "-->". If your audience has much older browsers, you should put this comments inside your javascript. If most of your audience has newer browsers, the comments can be omitted. For brevity, in most examples here the comments are not shown. ) The above code will look like this on Javascript enabled browsers,
2. Javascript can be placed inside the element Functions and global variables typically reside inside the element.
Default Test Page

Javascript can be referenced from a separate file Javascript may also a placed in a separate file on the server and referenced from an HTML page. (Don't use the shorthand ending "

Subscribe to

Add to Google
Add to My Yahoo!
Subscribe Via Web Feed
kick it on DotNetKicks.com