javascript - go on first page not working -
i'm trying create button go on first history page don't know why doesn't code work.this code:
function firstpg() { var startpt = '-' + window.history.length; window.history.go(startpt); } <!doctype html> <html> <head> </head> <body> <button onclick="firstpg()">go first</button> </body> </html> what problem?
the history includes current page need decrement 1 length in order go first page.
var startpt = '-' + ( window.history.length - 1) ; or
var startpt = -(window.history.length - 1) ;
Comments
Post a Comment