JS原生方法被覆盖后的恢复办法
alert 被覆盖
今天装修博客园,调试了下JS代码发现 alert() 方法被官方覆盖了,查看源码得知 alert 的功能被替换成了 console.log。
恢复
var _frame = document.createElement('iframe'); document.body.appendChild(_frame); window.alert = _frame.contentWindow.alert
官方有一套脚本过滤机制,主要是为了安全和体验上的考虑,不建议去绕过这种机制。