Get url for the page being opened next in window.onunload event

半世苍凉 提交于 2019-12-20 02:08:52

问题


Is there a way get the location for page being opened next in the window.onunload event.

Best Regards, Keshav


回答1:


No! That would be a security problem. Imagine someone navigating from a porn site to a banking site. The other way round (with the HTTP Referrer header) is already somewhat a headache. Firefox allows to suppress the referrer:

Enter about:config in the address bar Search for referer (sic) Set network.http.sendRefererHeader to 0

(Courtesy to http://cafe.elharo.com/privacy/privacy-tip-3-block-referer-headers-in-firefox/)




回答2:


The current page cannot and should not know where the user wants to go next (via address bar or bookmarks) (as @nalply said).

If your situation is you want to know which link that the use clicked on your page, then you can do this with javascript. Have a temporary variable that is populated with the URL everytime the user clicks on a link on your page. Then in window.onunload, you can use this.

If this is not your situation, can you tell your specific requirement on why you want to this? Perhaps you might get better solutions if you tell what you are trying to acheive.



来源:https://stackoverflow.com/questions/3186722/get-url-for-the-page-being-opened-next-in-window-onunload-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!