开发者

Javascript: detect when page has been navigated "back" to

Suppose I have a page open in a browser and I go to my address bar and enter another page. Then I hit the back button t开发者_如何学JAVAo go to my original page. I'd like to write some Javascript code that can detect this scenario and respond to it.

As best I can tell neither the ready event, the onload, nor any inline Javascript on the page itself is re-executed in this scenario. Is there anything else I can do?

Cross-browser support is important here. jQuery based solutions preferred but not required.

Edit for clarity: the navigation I'm assuming is Page A -> Page B -> back to page A where I'm assuming that Page B may or may not be under my control.


You should try to give the user a cookie on both pages, the navigated to page and the page itself, with dates and times and compare see if they're close, or if they show that he's been on one page, been on another, and then redirected.

Another option is to give the user a cookie when he is redirected


In Firefox, you can check for the DomContentLoaded event. For a cross-browser solution, a little more work is required:

http://dean.edwards.name/weblog/2005/09/busted/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜