Showing posts with label JavaScript HTML DOM Examples. Show all posts
Showing posts with label JavaScript HTML DOM Examples. Show all posts

Friday, August 31, 2012

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