[英]How to execute Javascript code in Chrome console?
I have a little application that generates some Javascript code, what can be executed on websites. 我有一个小应用程序,可以生成一些Javascript代码,这些代码可以在网站上执行。 To execute this code I'm using browser console and for Firefox it works well, but I can't figure out how to make it work with the Chrome browser.
要执行此代码,我使用了浏览器控制台,对于Firefox,它可以很好地工作,但是我不知道如何使其与Chrome浏览器一起使用。
In Firefox I'm generating this Javascript code: 在Firefox中,我正在生成以下Javascript代码:
javascript:var els = document.getElementById('video');els.style="";var none = document.getElementById('slika'); none.style="display:none;"
I open the console (CTRL-SHIFT-K), paste it, press ENTER and then the code is doing it's job. 我打开控制台(CTRL-SHIFT-K),将其粘贴,按Enter,然后代码即可完成工作。 I tried with Chrome via console (CTRL-SHIFT-J), in the address bar, but nothing happens.
我尝试通过控制台(CTRL-SHIFT-J)在地址栏中使用Chrome,但是没有任何反应。 If I'm trying in the console all I get is this line:
如果我在控制台中尝试,我得到的只是这一行:
"display:none;"
What does it stand for? 它代表什么? Is there some syntax error?
有语法错误吗?
If i try in the address bar, the browser redirects me to google and executes a query with the javascript code as search value :) 如果我在地址栏中尝试,浏览器会将我重定向到google并执行以javascript代码作为搜索值的查询:)
So I'm stuck with Chrome... 所以我坚持使用Chrome ...
Can someone help me out, please? 有人可以帮我吗? Thank you very much!
非常感谢你!
You don't need the javascript:
prefix if you're entering the code in the console. 如果您要在控制台中输入代码,则不需要
javascript:
前缀。
Also, I'm not sure if none.style="display:none;"
另外,我不确定是否
none.style="display:none;"
is valid. 已验证。 Try
none.style.display="none";
尝试
none.style.display="none";
if you're having problems with it. 如果您遇到问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.