[英]Is there a way to differentiate between elements with the same ID but in different browser tabs?
Let's say I have my website open in two tabs, and i want to get the element with the id "id", can I somehow get the element in the currently focused browser tab? 假设我在两个标签中打开了我的网站,并且我想获取ID为“ id”的元素,那么我能否以某种方式在当前集中的浏览器标签中获取该元素?
document.getElementById("id");
seems to get the element that was loaded most recently. 似乎得到了最近加载的元素。
No, since that would be a gaping security hole. 不,因为那将是一个巨大的安全漏洞。
There's a similar question on stackoverflow: Accessing the content of other tabs in browser . 在stackoverflow上也有类似的问题: 访问browser中其他选项卡的内容 。
This answer to the linked question provides code to do it, but I had problems in the past with IE, when trying to specify event handlers on the other document (worked fine in Firefox though). 链接问题的这个答案提供了执行此操作的代码,但是我过去在尝试在其他文档上指定事件处理程序时遇到了IE问题(尽管在Firefox中可以正常工作)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.