简体   繁体   中英

How to execute Javascript code in Chrome console?

I have a little application that generates some Javascript code, what can be executed on websites. 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.

In Firefox I'm generating this Javascript code:

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. I tried with Chrome via console (CTRL-SHIFT-J), in the address bar, but nothing happens. 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 :)

So I'm stuck with 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.

Also, I'm not sure if none.style="display:none;" is valid. Try none.style.display="none"; if you're having problems with it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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