4

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 Answers 4

8

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 ;)

Sign up to request clarification or add additional context in comments.

6 Comments

Of course if you have firebug you could just enter your commands directly into the console ...
yeah that would be a more optimal way of doing it
@Erik: Depends on what the OP wants to achieve.
I usually have fun putting JavaScript into the address bar. This isn't for debugging, but more for fun.
When I do this: javascript:x=$('.menu').css('border','1px solid #ff0000'), I get: [object Object] on the screen. Why?
|
3

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.

1 Comment

Darnit, didn't get to try that on 1/18 ;o
1

Yep. 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 it is by specifying a js file that first loads the JQuery library. maybe like this: http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.