Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery : Running script in the 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?

like image 893
contactmatt Avatar asked Dec 13 '22 23:12

contactmatt


2 Answers

One word: yes :)

Use Firebug or the IE developer tools like you normally would, make sure that the current page has script references to the jQuery library, then go to town on your selectors!

It's a good way to test selectors and functionality before incorporating it into your code

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

like image 145
Josh E Avatar answered Dec 15 '22 14:12

Josh E


Internet explorer address bar:

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

This example will un-blackout wikipedia (1/18/2012)

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

You have to alert the return value of the code because IE wants to place the return value on another page.

like image 20
AndyClaw Avatar answered Dec 15 '22 14:12

AndyClaw