You are here: Reference > JavaScript > client-side > browser > methods > go (history)

go method (history)

Browser support:
Loads a page from the history list into the current window.
If you need to load the next or the previous page, the forward and back method can also be used.


object.go (relativePosition);
You can find the related objects in the Supported by objects section below.


Required. Integer that specifies the relative position of a URL in the history list. For example go(-1) is equivalent to the back method, go(1) is equivalent to the forward method. This parameter can also be a string in Internet Explorer. In that case it specifies the exact URL of a document in the history list.

Return value:

This method has no return value.

Example HTML code 1:

This example illustrates the use of the go method.
    <script type="text/javascript">
        function GoBack () {
            history.go (-1);

        function GoForward () {
            history.go (1);
    Click on the following anchors first to add items to the history list.
    <br />
    <a href="#target1">First anchor</a>
    <a name="target1"></a>
    <br />
    <a href="#target2">Second anchor</a>
    <a name="target2"></a>
    <br /><br />
    Use these buttons to navigate in the history list:
    <button onclick="GoBack ();">go back in the history list</button>
    <button onclick="GoForward ();">go forward in the history list</button>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content