It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

how to run a js file from the address bar

how to run a js file from the address bar

Postby whininguser on Sat Jan 17, 2009 2:16 am

Instead of using javascript:alert('hi'), suppose I store alert('hi') in x.js and put it on host.com/x.js. Is it possible to execute host.com/x.js from the address bar using javascript:? Thanks.
whininguser
 
Posts: 2
Joined: Sat Jan 17, 2009 2:12 am

Re: how to run a js file from the address bar

Postby rangana on Sat Jan 17, 2009 6:19 am

When you go to the JS file, you will see the source code.

If you want to be able to run it via the address bar, you could copy and paste the entire code, and prefix it with javascript: pseudo-url.

For example, the contents of host.com/x.js is:
Code: Select all
alert('hi');
alert('hello');


...copy that code, and place that in the address bar on this format:
Code: Select all
javascript:alert('hi');alert('hello');


Hope that helps.
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines


Who is online

Users browsing this forum: No registered users and 8 guests