Javascript chrome扩展中的window.onbeforeunload
我想防止框架破坏通过铬延长。特别是,我想使用本文()中引用的方法,但我不能直接访问html页面。有没有一种方法可以使用chrome extension来实现下面的windows.onbeforeunload的等效功能?我读过,但不确定这些是否适用于这种情况 www.example.com中的框架分解代码Javascript chrome扩展中的window.onbeforeunload,javascript,google-chrome,google-chrome-extension,Javascript,Google Chrome,Google Chrome Extension,我想防止框架破坏通过铬延长。特别是,我想使用本文()中引用的方法,但我不能直接访问html页面。有没有一种方法可以使用chrome extension来实现下面的windows.onbeforeunload的等效功能?我读过,但不确定这些是否适用于这种情况 www.example.com中的框架分解代码 if (parent.location != self.location) { parent.location = self.location ; } 我想让chrome扩展做的是与下
if (parent.location != self.location) {
parent.location = self.location ;
}
我想让chrome扩展做的是与下面相同的事情
<script>
window.onbeforeunload = function() {
return ”Asking the user nicely”;
}
</script>
<iframe src = ”http://www.example.com”>
window.onbeforeunload=函数(){
返回“友好地询问用户”;
}
如果您使用chrome扩展,那么如果您使用的是内容脚本Hanks Pavlo,您就可以直接访问该页面-我认为在阅读了内容脚本之后,这也是一种方式。onbeforeunload不再在现代浏览器中显示自定义消息。