Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
47
rated 0 times [  50] [ 3]  / answers: 1 / hits: 15125  / 14 Years ago, tue, september 28, 2010, 12:00:00

As the title says, will this code work and will it work in major browsers?



I ask because currently I have no resources to test it, so I would appreciate some help on this.



Here is what I have (not tested):



setTimeout(window.location.history.go(-2), 5000);


Thanks


More From » html

 Answers
117
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?


[#95481] Friday, September 24, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jaidyn

Total Points: 633
Total Questions: 102
Total Answers: 100

Location: Trinidad and Tobago
Member since Thu, Dec 1, 2022
2 Years ago
jaidyn questions
Fri, Feb 11, 22, 00:00, 2 Years ago
Fri, May 14, 21, 00:00, 3 Years ago
Wed, Oct 30, 19, 00:00, 5 Years ago
;