WHAT A LAMP Rotating Header Image

Posts Tagged ‘JavaScript’

JavaScript Classes Comparison

There are more and more JavaScript Classes in front of programers. To choose one of the suitable is very important.
Let me list some of them here: jQuery, Ext, MooTools, Prototype, YUI.
Remy Sharp has gone through the jQuery and Prototype frameworks, which are probably the two closest to each other, and has done a side by [...]

Loops of JavaScript

Loops in JavaScript are used to execute the same block of code a specified number of times or while a specified condition is true.
JavaScript Loops
Very often when you write code, you want the same block of code to run over and over again in a row. Instead of adding several almost equal lines in a [...]

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.
The Code is shown as below.

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 specific date (14th January 2010):

var [...]

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

15/5 5/2
3 2.5

%
Modulus (division remainder)
5%2 10%8 10%2
1 2 0

++
Increment
x=5 x++

x=6


Decrement
x=5 x–
x=4

Assignment [...]

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 type="text/javascript">
….
</script>
</head>
JavaScripts in the head [...]

What is Javascript

What is JavaScript?
* JavaScript was designed to add interactivity to HTML pages
* JavaScript is a scripting language (a scripting language is a lightweight programming language)
* A JavaScript consists of lines of executable computer code
* A JavaScript is usually embedded directly into HTML pages
* JavaScript is an interpreted language (means that scripts execute without preliminary compilation)
* [...]