There are different situations when you may want to use an external javascript file. One idea may be to reference a single script from different web pages. Another idea may to be to conform closer to the W3C standards. Perhaps the reason is “just because”.
Having an external JavaScript page is similar to having an external [...]
Sometimes images can be a bit large in memory size. Having a rollover effect work efficiently means it should work properly from the start of the page being loaded. Without a preload, there may be a short delay in the rollover effect at first since the browser will only download images as they become “active” [...]
Rollovers, Mouseovers, Image Swaps… It goes by many variations of names, but means the same thing. Making one image change into a different one when a mouse pointer goes over a specified area.
The first thing you will need are 2 images. One for normal view, a second for the change.
The first image will be placed [...]
Timeouts are like a timer. It can allow you to execute a section of code after a specified amount of time has passed. If you have viewed this page for 30 seconds, you have probably noticed a working example of this. Here is the code used :
//
<script type=”text/javascript”>
<!–
setTimeout(“alert(‘Thirty seconds has passed.’);“,30000);
// –>
</script>
Notice that the [...]
If JavaScript is the only type of “script” language you are using on the page, you can specify a BASE setting and not have to include the TYPE for each SCRIPT. This is commonly done when there are many areas of script within the page code.
The BASE setting is created using a META tag. These [...]
The GET command is used to retrieve a part of the current date or time. The information is constructed from the visitor’s computer settings.
The different types of GET are :
getFullYear( )
getMonth( )
getDate( )
getDay( )
getHours( )
getMinutes( )
getSeconds( )
The year
The month
The day of the month
The day of the week
The hour
The minutes
The seconds
4 digits
0 to 11
1 to 31
1 [...]
Control structures are simply the deciding factors for what sets of codes are going to be used and how they are going to be used. These structures consist of :
IF ELSE
WHILE
FOR
These three control structures are very similar. Each of the three control structures has its own specific format and its own special [...]
Arrays are used to organize a set of variables.
Here is an example of a regular script defining 10 names using variables.
<script type=”text/javascript”>
<!–
var a=”Joe”;
var b=”Peter”;
var c=”Mary”;
var d=”Chris”;
var e=”Dave”;
var f=”Sally”;
var g=”Pat”;
var h=”John”;
var i=”Larry”;
var j=”Andrew”;
// –>
</script>
This can become a very hard task when you have to remember which variable is holding which name. Not to mention you will [...]
FUNCTIONS are small groups of instructions that are carried out when they are called upon. They are usually placed in the HEAD area of the page code. If you have a page that will be doing the same task many times, it’s best to use a function to organize them.
A very basic example of how [...]
Before getting into the actual JavaScripting parts, here are a few other bits of information that will help you along the way.
alert
Generates a pop-up ALERT box. This provides information and visitor clicks on OK to continue.
confirm
Generates a pop-up CONFIRM box. This gives the visitor an OK or CANCEL choice.
document
Refers to the current document or page [...]