javascript - 如何在 Chrome DevTools 中中断 document.write?

标签 javascript debugging google-chrome-devtools document.write

有没有办法在页面加载期间中断/触发 document.write() 上的调试器,而不知道它会发生在哪里?

整个页面被一些第三方广告提供商代码所震撼,这些代码必须在没有 iframe 的情况下执行,但我必须找到一种方法来识别这些问题的根源。

最佳答案

您可以重写document.write()函数:

<script language="javascript">
 document.write =(exp1, exp2, exp3, ...)=> {
   console.log('test');
 }
</script>

<!--  Write is then called somewhere-->
<script language="javascript">
 document.write();
</script>

更新

另一个解决方案是使用 chrome devtools 事件监听器断点:

enter image description here

关于javascript - 如何在 Chrome DevTools 中中断 document.write?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50796234/

相关文章:

javascript - 使用Jquery限制浏览器窗口高度不能小于200px?

linux -/proc/kmsg 和 dmsg 有什么区别?

ios - _UIRemoteView - 在 Xcode 中显示 View 层次结构

html - 为什么 chrome 移动 Debug模式设置了更大的 html 正文宽度而不是设备宽度?

google-chrome - Chrome Dev Tools 水平拆分

javascript - 单击浏览器后退按钮时将用户返回到他们在上一页上滚动到的位置

javascript - 未捕获的语法错误 : Unexpected token ILLEGAL in asp. 网络

javascript - 如何避免 NodeJs、Express 中的 If else hell

debugging - 如何调试Rexx代码?

javascript - 在事先不知道方法的情况下,如何在调试时找出 Javascript 中调用了哪些方法?