JavaScript Browser Objects Examples
Examples of using JavaScript to access and manipulate the Browser objects.
Window Object
Open a new window when clicking on a button
Open a new window and control its appearance
Blur and Focus a new window
Close the new window
Checks whether the new window has been closed or not
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
Screen Object
The visitor's screen: Width
The visitor's screen: Height
The visitor's screen: Available Width
The visitor's screen: Available Height
The visitor's screen: Color Depth
The visitor's screen: Pixel Depth
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
Replace the current document
Break out of a frame
History Object
Display 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
Navigator Object
Is cookies enabled in the visitor's browser?
What is the name of the visitor's browser?
What is the engine name of the visitor's browser?
What is the version information of the visitor's browser?
What is user agent information of the visitor's browser?
What is the platform of the visitor's browser?
What is the language of the visitor's browser?
Is Java enabled in the visitor's browser?
Popup Boxes
Display an alert box
Demonstrate line breaks in an alert box
Display a confirm box
Display a prompt box
Timing
Simple timing
Another simple timing
Timing event in an infinite loop
Timing event in an infinite loop - with a Stop button
A clock created with a timing event
Set and stop a timer with setInterval() and clearInterval()