如何在卸载前更改我的网站的网址?

时间:2021-03-18 22:28:53

标签: javascript html jquery onbeforeunload window.location

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

1 个答案:

答案 0 :(得分:1)

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

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

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