JavaScript Browser Objects Examples

« Previous Next Chapter »

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

All details about the visitor's browser

More Navigator object examples in our JavaScript reference.

Screen Object

All details about the visitor's screen

More Screen object examples in our JavaScript reference.

History Object

Return the number of URLs in the history list
Create a back button on a page
Create a forward button on a page
Load a specific URL from the history list

More History object examples in our JavaScript reference.

Location Object

Return the hostname and port of the current URL
Return the entire URL of the current page
Return the path name of the current URL
Return the protocol portion of the current URL
Load a new document
Reload the current document
Replace the current document
Break out of a frame

More Location object examples in our JavaScript reference.


« Previous Next Chapter »