setTimeout(window.location.history.go(-2), 5000);
history
is a property of window
, not location
. Also if you want it to trigger after a delay you will need to make a delayed-call function—currently you are calling go()
immediately, and passing the return value of the function to setTimeout
, which clearly won't work. You probably mean:
setTimeout(function() {
history.go(-2);
}, 5000);
As for ‘go back two pages’, yes, it'll work in pretty much all JS-supporting browsers, but it's the kind of thing users are likely to find incredibly confusing. Are you sure you want to do that?