JavaScript Browser Object
Examples
Using JavaScript to access and control browser object instances.
Window Object
- Pop up an alert box
- Pop up an alert box with a line break
- Pop up a confirm box and remind the visitor of the clicked content
- Pop up a prompt box
- Open a new window when a button is clicked
- Open a new window and control its appearance
- Open multiple new windows
- Ensure the new window does not get focus
- Ensure the new window gets focus
- Close the new window
- Check if the new window is closed
- Return the name of the new window
- Transfer some text to the source (parent) window
- Move the new window relative to the current position
- Move the new window to a specified position
- Print the current page
- Specify window size in pixels
- Specify window size
- Scroll content by specified pixels
- Scroll to specified content
- A simple clock
- Set and stop timers with setTimeout() and clearTimeout()
- Set and stop timers with setInterval() and clearInterval()
- More examples of the Window object can be found in our JavaScript Reference Manual.
Navigator Object
- Details of the visitor's browser
- More examples of the Navigator object can be found in our JavaScript Reference Manual.
Screen Object
- Details of the visitor's screen
- More examples of the Screen object can be found in our JavaScript Reference Manual.
History Object
- Return a list of URLs in history
- Create a back button
- Create a forward button
- Go to a specified URL from the history list
- More examples of the History object can be found in our JavaScript Reference Manual.
Location Object
- Return the hostname and port number of the current URL
- Return the entire URL of the current page
- Return the pathname of the current URL
- Return the protocol part of the current URL
- Load a new document
- Reload the current document
- Replace the current document
- Break out of frames
- More Location object examples can be found in our JavaScript Reference Manual.