So you saw someone using a few effects on their page and you thought it was cool, huh? Well, that might have been javascript (nowadays, that might be AJAX) that you saw. So now you know, but how do you make those pretty, shiny effects work for you?
Maybe I can tell you a little.
As far as the background goes, javascript is an object oriented language for web coding that revolves around the Document Object Model (commonly referred to as the DOM). For a better explanation than I could explain, check out w3schools' intro to Javascript.
Heck, you may even want to read their whole tutorial, but I am going to write this one anyway.
When you want to write javascript, you can write it either internally or externally. Since most Javascript that is seen for the average website is internal, I am going to approach things from that angle. Internal javascript can be in the <head> tag or the <body> tag. Most of the time it lives in the head tag if you have parts of your javascript that need to run before the page loads. However, you can also put it in the <body> tag if you don't care whether the javascript runs before the page load or after.
Where does Javascript live? Well, it's mansion can be found within the rolling hills of the <script> tag like this:
- Code: Select all
.
.
.
<head>
<script ...>
your javascript stuff
</script>
</head>
.
.
.
Since Javascript isn't the only kind of script there is, you have to tell your script tag "I'm writing Javascript!" In order to do that, you can write like this:
- Code: Select all
.
.
.
<script language="text/javascript">
.
.
.
It will run just fine. Now, if you are wanting to validate your page using w3c or a similar site, you may run into a few snafu's if you use the format I just gave you because XHTML Strict 1.x standard web pages see that <script> tag as malformed. Because of this, if you are using the XHTML Strict standard, then please use the following:
- Code: Select all
.
.
.
<script type="javascript">
.
.
.
Alternately, I think you could use "type='text/javascript'" and still be okay.
Now while I would to tell you all about the wonderful things you can do with this now, it will be better if I make you wait until the next installation where I talk to you about objects and methods, so until next time.






