Friday, August 31, 2012

JavaScript and HTML DOM Reference


JavaScript Objects Reference

The references describe the properties and methods of each object, along with examples.

Browser Objects Reference

The references describe the properties and methods of each object, along with examples.

Core DOM Objects Reference

The references describe the properties and methods of each object, along with examples.

HTML DOM Objects Reference

The references describe the properties and methods of each object, along with examples.

JavaScript Quiz Test


You can test your JavaScript skills with W3Schools' Quiz.

The Test

The test contains 20 questions and there is no time limit.
The test is not official, it's just a nice way to see how much you know, or don't know, about JavaScript.

Count Your Score

You will get 1 point for each correct answer. At the end of the Quiz, your total score will be displayed. Maximum score is 20 points.

JavaScript HTML DOM Examples


Examples of using JavaScript to access and manipulate the HTML DOM objects.

Document Object

Write text to the output with document.write()
Write formatted text to the output with document.write()
Return the number of anchors in a document
Return the innerHTML of the first anchor in a document
Return the number of forms in a document
Return the name of the first form in a document
Return the number of images in a document
Return the id of the first image in a document
Return the number of links in a document
Return the id of the first link in a document
Return all name/value pairs of cookies in a document
Return the domain name of the server that loaded the document
Return the date and time the document was last modified
Return the URL of the document that loaded the current document
Return the title of a document
Return the full URL of a document
Open an output stream, and add some text
Open an output stream in a new window, and add some text
Difference between write() and writeln()
Alert innerHTML of an element with a specific ID
Alert the number of elements with a specific name
Alert the number of elements with a specific tagname
More Document object examples in our JavaScript reference.

Anchor Object

More Anchor object examples in our JavaScript reference.

Area Object

More Area object examples in our JavaScript reference.

Base Object

More Base object examples in our JavaScript reference.

Button Object

More Button object examples in our JavaScript reference.

Form Object

More Form object examples in our JavaScript reference.

Frame/IFrame Objects

More Frame/IFrame object examples in our JavaScript reference.

Image Object

More Image object examples in our JavaScript reference.

Event Object

onblur - Execute a JavaScript when a user leaves an input field
onchange - Execute a JavaScript when a user changes the content of an input field
onclick - Execute a JavaScript when a button is clicked
ondblclick - Execute a JavaScript when a button is double-clicked
onerror - Execute a JavaScript if an error occurs when loading an image
onfocus - Execute a JavaScript when an input field gets focus
onkeydown - Execute a JavaScript when a user is pressing/holding down a key
onkeypress - Execute a JavaScript when a user is pressing/holding down a key
onkeyup - Execute a JavaScript when the user releases a key
onload - Execute a JavaScript immediately after a page has been loaded
onload - Execute a JavaScript immediately after an image has been loaded
onmousedown + onmouseup - Execute scripts when pressing/releasing a mouse button
onmousedown - Alert which mouse button the user pressed
onmousedown - Alert the name of the element a user clicked on
onmousemove + onmouseout - Execute scripts when moving the mouse pointer over/out of an image
onmouseover + onmouseout - Execute scripts when moving the mouse over/out of an image
onresize - Execute a JavaScript when the browser window is resized
onselect - Execute a JavaScript after some text has been selected
onunload - Execute a JavaScript before the browser closes the document
What is the keycode of the key pressed?
What are the coordinates of the cursor?
What are the coordinates of the cursor, relative to the screen?
Was the shift key pressed?
Which event type occurred?

Option and Select Objects

Table, TableHeader, TableRow, TableData Objects


JavaScript Browser Objects Examples


Examples of using JavaScript to access and manipulate the Browser objects.

Window Object

Display an alert box
Display an alert box with line-breaks
Display a confirm box, and alert what the visitor clicked
Display a prompt box
Create a pop-up window Open a new window when clicking on a button
Open a new window and control its appearance
Open multiple new windows
Assure that the new window does NOT get focus (send it to the background)
Assure that the new window GETS focus
Close the new window
Checks whether the new window has been closed or not
Return the name of the new window
Write some text to the source (parent) window
Move the new window relative to its current position
Move the new window to the specified position
Print the current page
Resize a window by the specified pixels
Resize a window to a specified size
Scroll the content by the specified number of pixels
Scroll the content to a specified position
A simple timing
Set and stop a timer with setTimeout() and clearTimeout()
Set and stop a timer with setInterval() and clearInterval()
More Window object examples in our JavaScript reference.

Navigator Object

More Navigator object examples in our JavaScript reference.

Screen Object

More Screen object examples in our JavaScript reference.

History Object

More History object examples in our JavaScript reference.

Location Object

More Location object examples in our JavaScript reference.