简体   繁体   English

如何在打开的选项卡上检测URL更改

[英]How to detect a URL change on a opened tab

I have to open a new tab in javascript and I would like to be noticed (on the main tab, the first one), if the user close the tab or if the user change the url. 我必须在javascript中打开一个新标签,并且如果用户关闭该标签或更改了网址,希望在主标签上显示第一个标签。 I know that if the second tab is on an other domain, you cannot access to the location attributes and I understand. 我知道,如果第二个选项卡在另一个域上,则您将无法访问位置属性,并且我了解。 But is there any way to detect if the user changes the URL of the child tab ? 但是,有什么方法可以检测用户是否更改了子选项卡的URL? A kind of bit or flag giving me this information ? 给我这些信息的一种方式?

In advance, thank you. 预先谢谢你。

更改URL将导致页面的重新加载,因此您应该检测何时重新加载页面,因此: 检查是否用Javascript重新加载或刷新了页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM