var win = window.open('url')
我想阻止弹出窗口中的警报消息,win。
我知道当前窗口中阻止警报消息。
window.alert = function() {
console.log('test');
}
此代码替换原始警报消息。
但是,如何实现类似的弹出页面呢?
win.window.alert = function() {
console.log('test');
}
未设置。
最佳答案
如果 URL 位于同一域,则这应该可以工作(返回的 win
已经是 Window
对象):
win.alert = function() {
console.log('test');
}
如果不是来自同一个域,则无能为力;出于安全原因,同源策略禁止干扰从其他来源加载的页面范围。
Source :
The returned
Window
reference can be used to access properties and methods of the new window as long as it complies with Same-origin policy security requirements.
关于javascript - 如何屏蔽弹出页面的提醒信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51513288/