Is it possible to load remote JavaScript files from the address bar?
I have been trying to put this into the address bar:
javascript:src='http://depot.com/file.js';funcname();
I’m not using this for bad things. I’m just testing my site, that’s all. If you wanted to protect your site you must learn to attack it first, right?
I guess you should be able to do the following:
Here’s a very useful example (paste this in your address bar):
Voila:
In fact, this is how cornify.com is including the remote scripts in their bookmarklet.
UPDATE:
As @Ben noted in the other answer, it’s not that straightforward to call a function defined in your remote script. Ben suggests one solution to this problem, but there is also another solution, the one that cornify are using. If you check out
http://cornify.com/js/cornify_run.jsyou’ll see that there’s just one function call in that file. You could place yourfuncname()call in a separate JavaScript file, as cornify are doing, because script blocks are guaranteed to be executed in the order they are inserted. Then you’d have to include both scripts, as in the following example:Where the
file_run.jssimply includes a call tofuncname().