Welcome to Bucaro TecHelp!

Bucaro TecHelp
HTTPS Encryption not required because no account numbers or
personal information is ever requested or accepted by this site

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact RSS News Feeds News Feeds

The Browsers History Object

The Back and Forward buttons are related to the browser's history object. As the user surfs the Web, the history object maintains a list of the URLs they visited. When you select the browser's History menu item you can view the contents of the history object.

The history object is not in the browser's DOM (document object model) because it's not a visual object, it's a list of past pages that were loaded into the browser. For security reasons, there is very little you can do with the history object, for example you can't examine the URL's of the previous websites that the user visited.

The history object's back() method moves the browser back one page in the history list. Shown below is the code for a Back button using the history object's back() method:

<input type="button" value="Back" onclick="history.back()" />

If the user executed the history object's back() method, or clicked the browsers Back button at least once, then the browser will be at a previously visited URL in the history list and the history object's forward() method can be used to move the browser forward one page in the history list.

Shown below is the code for a Back button using the history object's forward() method:

<input type="button" value="Forward" onclick="history.forward()" />

The history object's go() method accepts an integer value that moves the browser that many pages in the history list from its current location in the list. If the value passed to the go() method is a negative value, it will move the browser backward in the history list. If the value passed to the go() method is a positive value, it will move the browser forward in the history list.

Shown below is the code for a Back button using the history object's go() method that moves the browser backward 2 pages in the history list:

<input type="button" value="Back" onclick="history.go(-2)" />

Passing the value 0 to the go() method reloads the current page, which may be something you need to do in code, for example, if a user has not completed a form properly.

More Java Script Code:
• Java Script Character Encoding and Decoding
• The do/while Loop
• Get Webpage File Date and File Size
• The Document Object Model (DOM)
• Determine Minimum and Maximum
• Java Script alert Message Box
• Generating Random Numbers
• Java Script confirm Message Box
• Java Script Math.tan Method
• Extract Part of a String

RSS Feed RSS Feed

Follow Stephen Bucaro Follow @Stephen Bucaro


Fire HD
[Site User Agreement] [Privacy Policy] [Site map] [Search This Site] [Contact Form]
Copyright©2001-2024 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268