JQuery: running script in address bar

In most web browsers, you can execute JavaScript in the address bar (i.e.

javascript:alert('Test');

Is it possible to execute jQuery in the address bar?

+4
source share
4 answers

One word: yes :)

Use Firebug or the IE developer tools, as usual, make sure the current page has script links to the jQuery library, then go to the city on your selectors!

This is a good way to test the selector and functionality before including it in your code.

EDIT: read the question a bit wrong, but the answer is still the same. Whether it's an address bar or a console window, you can use jQuery. Try putting javascript:$("#content").remove() in your address bar while viewing this page and see what happens;)

+8
source

Internet Explorer Address Bar:

 javascript:alert(eval('put any block of code here')) 

In this example, wikipedia will be disabled (1/18/2012)

 javascript:alert(eval('$("#mw-sopaOverlay").hide(); $("#content").show();')) 

You should warn the return value of the code because IE wants to place the return value on another page.

+3
source

Yeah. here's an example where jquery is already on the page: https://meta.stackexchange.com/questions/20420/countdown-app-for-devdays/20430#20430

Another way you could do this is to specify a js file that first loads the jQuery library. maybe like this: http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml

+1
source

javascript: void (eval ('put any block of code here))

+1
source

Source: https://habr.com/ru/post/1302083/


All Articles