I'm cr开发者_如何学运维eating a homepage. The content of the page is only get by HTTP-Request. So that the Client never change the page-url. How can I catch the back() function from the Browser to go one step back in my HTTP-Request. The automaticly creating of History of all loaded HTTP-Request is done, maybe I must catch this back() function.
Thanks for Help
You might want to update the hash (www.mysite.com/#hash
) and then use a mechanism to detect hash change.
Try using this: Browser Back Button Detection
As far as I'm aware you cannot interfere with the back button etc. as it affects the browsers UX.
The best way would probably be to catch the browsers 'onunload' event which is triggered when the page is left. You could write a custom handler function on the assumption that they are clicking back.
If you want to get the page the user come from, you can use the document.referrer
(more info on getting last page URL from history object - cross browser?).
Then you could use this to create a link if needed.
Regards,
Max
精彩评论