Popup boxes is used very often in Web developing. Alert Box An alert box is often used if you want to make sure information comes through to the user. When an alert box pops up, the user will have to click “OK” to proceed. Syntax: alert(“sometext”) Confirm Box A confirm box is often used if [...]
Posts from ‘March, 2007’
JavaScript Version
JavaScript from v1.1 to JavaScript 1.5. It is not big problem. Now, Javascript 1.5 is work smoothly on IE6.0 and Navigator 6.0. If you want to know which JavaScript version your browser support, you can download this html file and load it in your browser. Or you can run it by JavaScript Version Detector here. [...]
Date function in JavaScript
Return today’s date and time How to use the Date() method to get today’s date. The following code line defines a Date object called myDate: var myDate=new Date() Note: The Date object will automatically hold the current date and time as its initial value! In the example below we set a Date object to a [...]
Why use cookies
Cookies allow you to store information about a user’s visit on that user’s computer and retrieve it when the userrevisits your site. Two common reasons web developers use cookies are To idetify visitors You can detect when a user has previously visited your site and customize what that user sees on subsequent visits. To save [...]
Data types
There are two data types that JavaScript requires you to explicitly specify: the Array and Data data types. JavaScript supports the following data types: Array An ordered collection. For example: var animals = new Array (“cat”, “dog”, “mouse”) Boolean True/false data type (values of true or false only). For example: var cookieDetected = false var [...]
Make a Function
A function is a named group of JavaScript statements that you can declare once, near the top of your script, and call over and over again. Declaring a function function name ([parameter] [, parameter] [..., paramenter]){ statements return value } Call a function alert(“Total purchases come to ” + calculateTotal (10, 19.85)) Returning a value [...]
Working with variables
A variable is a named placeholder for a value. You can use the var keyword to construct an expression that first declares a variable and then (optionally) initializes its value. How to declare a variable: var myName; How to initialize a value: var myName = “David Yin” Technically, you can declare a variable in JavaScript [...]
Operators of JavaScript
Every computer language has operators. JavaScript has following items: There are two categories of operators. Binary: Two items (or operands) must be sandwiched on either side of the operator. Unary: onely one operand is required. Arithmetic Operators Operator Description Example Result + Addition x=2y=2x+y 4 – Subtraction x=5y=2x-y 3 * Multiplication x=5y=4x*y 20 / Division [...]
Add comments to scripts
The JavaScript interpreter ignores comments. Comments do have value, though; they’re very useful for explaining things to human readers of your script. Of course, including yourself. 1) Single-line comment //Single-line comments don’t require an ending slash. 2) Multiple-line comment /* This comment can span multiple lines. Always remember to close it. Though; if you forge. [...]
Where to put Javascript
JavaScripts in the body section will be executed WHILE the page loads. Scripts will be executed when they are called, or when an event is triggered, go in the head section. When you place a script in the head section, you will ensure that the script is loaded before anyone uses it. <html> <head> <script [...]


