【问题标题】:how do I change the url of my site before unload?如何在卸载前更改我的网站的网址?
【发布时间】:2021-06-16 09:08:35
【问题描述】:

所以我有一个页面,通过单击更改网站正文中显示内容的选项卡进行导航,当您转到新选项卡(在网站中)时,它会更改 url。例如,我在主页选项卡中,url 更改为https://a.website.com/home,然后我转到 changelog 选项卡,url 更改为https://a.website.com/changelog。这些网址中的任何一个实际上都不存在,所以当用户重新加载时,我将如何做到这一点,他们将被定向到https://a.website.com,而不是找不到页面错误页面? 可能使用window.onbeforeunload

【问题讨论】:

  • “当用户重新加载时”你的意思是当他们按下浏览器的“重新加载此页面”按钮或组合键时?还是你的意思是别的?

标签: javascript html jquery onbeforeunload window.location


【解决方案1】:

标记正在用作页面参数的选项卡:

https://a.website.com?tab=home
https://a.website.com?tab=changelog

然后,您可以决定在您的页面上显示哪个标签。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-01-22
    • 1970-01-01
    • 1970-01-01
    • 2016-01-27
    • 2015-03-04
    • 2019-06-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多