JavaScript ObjectExamples
Examples of using built-in JavaScript objects.
Document Object
- Use document.write() to output text
- Use document.write() to output HTML
- 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 the name/value pairs of all cookies in a document
- Return the server domain of the loaded document
- Return the last modified time of a document
- Return the URL of the currently loaded document
- Return the title of a document
- Return the full URL of a document
- Open an output stream and write text to the stream
- The difference between write() and writeln()
- Pop up the innerHTML of an element with a specified ID
- Pop up the number of elements with a specified name
- Pop up the number of elements with a specified tag name
- More Document object examples in ourJavaScript Reference Manual.
Anchor Object
- Return and set the charset attribute of a link
- Return and set the href attribute of a link
- Return and set the hreflang attribute of a link
- Return the name of an anchor
- Return the relationship between the current document and the linked document
- Change the target attribute of a link
- Return the value of the type attribute of a link
- More Anchor object examples in ourJavaScript Reference Manual.
Area Object
- Return the alternate text of a certain area in an image map
- Return the coordinates of a certain area in an image map
- Return the anchor part of the href attribute of an area
- Return the hostname:port of a certain area in an image map
- Return the hostname of a certain area in an image map
- Return the port of a certain area in an image map
- Return the href of a certain area in an image map
- Return the pathname of a certain area in an image map
- Return the protocol of a certain area in an image map
- Return the querystring part of the href attribute of an area
- Return the shape of a certain area in an image map
- Return the value of the target of a certain area in an image map
- More Area object examples in ourJavaScript Reference Manual.
Base Object
- Return the base URL for all relative URLs on a page
- Return the base link for all relative links on a page
- More Base object examples in ourJavaScript Reference Manual.
Button Object
- Make a button disabled after clicking it
- Return the name of a button
- Return the type of a button
- Return the value of a button
- Return the ID of the form a button belongs to
- More Button object examples in ourJavaScript Reference Manual.
Form Object
- Return the value of all elements in a form
- Return the value of the acceptCharset attribute of a form
- Return the value of the action attribute of a form
- Return the value of the enctype attribute in a form
- Return the number of elements in a form
- Return the method for sending form data
- Return the name of a form
- Return the value of the target attribute of a form
- Reset a form
- Submit a form
- More Form object examples in ourJavaScript Reference Manual.
Frame/IFrame Object
- Style an iframe
- Change the background color of a document contained in an iframe
- Return the value of the frameborder attribute in an iframe
- Remove the frameborder of an iframe
- Change the height and width of an iframe
- Return the value of the longdesc attribute in an iframe
- Return the value of the marginheight attribute in an iframe
- Return the value of the marginwidth attribute in an iframe
- Return the value of the name attribute in an iframe
- Return and set the value of the scrolling attribute in an iframe
- Change the src of an iframe
- More Frame/IFrame object examples in ourJavaScript Reference Manual.
Image Object
- Style an image
- Return the alternate text of an image
- Add a border to an image
- Change the height and width of an image
- Set the hspace and vspace attributes of an image
- Return the value of the longdesc attribute of an image
- Create a link pointing to a low-resolution image
- Return the name of an image
- Change the src of an image
- Return the value of the usemap of a client-side image map
- More Image object examples in ourJavaScript Reference Manual.
Event Object
- The keycode of the pressed keyboard key?
- Mouse coordinates?
- Mouse coordinates relative to the screen?
- Is the Shift key pressed?
- Which event occurred?
Option and Select Object
- Disable and enable a drop-down list
- Get the ID of the form containing a drop-down list
- Get the number of options in a drop-down list
- Turn a drop-down list into a multi-line list
- Select multiple options in a drop-down list
- Pop up the selected option in a drop-down list
- Pop up the index of the selected option in a drop-down list
- Change the text of the selected option in a drop-down list
- Remove options from a drop-down list
Table, TableHeader, TableRow, TableData Object
- Change the width of a table border
- Change the cellpadding and cellspacing of a table
- Specify the frame of a table
- Specify rules for a table
- The innerHTML of a row
- The innerHTML of a cell
- Create a caption for a table
- Delete rows from a table
- Add rows to a table
- Add cells to a table row
- Align cell content horizontally
- Align cell content vertically
- Horizontally align the content of a single cell
- Vertically align the content of a single cell
- Change the content of a cell
- Change the content of a row