Window history.go() method

Definition and usage

history.go() Method loads a URL (page) from the history list.

history.go() Method is only valid when the page exists in the history list.

Comment

history.go(0) Reload the page.

history.go(-1) With history.back() Same.

history.go(1) With history.forward() Same.

See also:

history.back() method

history.forward() method

history.length method

Example

Create a button to go back two pages:

<button onclick="history.go(-2)">Go back two pages</button>

The output of the above code will be:

Click back to see how it works.

(Yana dake a dukiya dake a kuduwa da kuduwa a dukiya kuduwa)

Try it yourself

Syntax

history.go(number)

Parameter

Parameter Description
number Zaruri. Katanin dake a daidai. Yuki dake a aiki.

Return value

Ba wani.

Dukiya suka

Dukiya dake a dukiya suka history.go()

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
支持 支持 支持 支持 支持 支持