简体   繁体   English

Chrome调试器注入了javascript

[英]Chrome debugger inject javascript

I have this curiosity, 我有这种好奇心,

Is it, in some way, possible to inject javascript in my page and execute it and debug it? 在某种程度上,它是否可以在我的页面中注入javascript并执行并调试它? As you do with the console, but in the console you can't pause and watch variables. 与控制台一样,但在控制台中,您无法暂停和查看变量。

Is it possible to debug code that i put through console? 是否可以调试我通过控制台提供的代码? Why isn't it possible to debug code received via XHR? 为什么不能调试通过XHR接收的代码?

Thanks! 谢谢!

One trick I learned today from Chromium is that if you place the word: 我今天从Chromium学到的一个技巧是,如果你放置这个词:

debugger;

Right before the statement you want to debug. 在您要调试的语句之前。 It will break on the debugger. 它将打破调试器。 It is really useful for injected scripts. 它对注入的脚本非常有用。

yes, its possible to include the javascript function in our webpage by using 是的,它可以通过使用在我们的网页中包含javascript函数

window.onload = function fun(){alert("test");}

with in this event u can give a statement or any function. 在这种情况下,你可以发表声明或任何功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM