HannahI 0 Report post Posted November 3, 2009 (edited) Hi Guys,There is a thing a like to call "URL JS".It lets you run javscript in the browser directly from the URL bar.If you don't understand me, type "java script:alert("hello");" without the space in the browser.Can you teach me how to do real things with it other than making an alert box?Thanks,-Hannah Edited November 3, 2009 by HannahI (see edit history) Share this post Link to post Share on other sites
FirefoxRocks 0 Report post Posted June 24, 2010 It's the same as any regular JavaScript you use on a web page, but depending on your browser's security settings (most notably Internet Explorer's Trust/Local Intranet Zone), some JavaScript may not be allowed to be executed through the address bar, which can be a good thing. An example of your so-called "URL JS" would be a bookmarklets. Share this post Link to post Share on other sites
yordan 10 Report post Posted June 25, 2010 "java script:alert("hello");"I don't see where the problem is.Exactly as the syntax says, it's an alert, it opens an alert in order to warn you that "hello".It can be very useful if you want to rise an alert in order to warn the user that what he is doing is not exactly what you wanted him to do.For instance if you want him to enter his password and the program enters on some place where you need the password to have been typed in and it has not been entered, you can "alert" the user with a message gently warning him, like : "Sorry Sir, could you please type your password?"Then go back to the main loop getting the password and restart with a valid value. Share this post Link to post Share on other sites
FirefoxRocks 0 Report post Posted June 27, 2010 I think that the op meant that the alert function wasn't too useful in "URL JS", which really isn't, what's the point of typing that line in your address bar to create an alert box? Share this post Link to post Share on other sites
Quatrux 4 Report post Posted June 27, 2010 (edited) Well, the java script: in an url is used if you want to call a javascript function or something, it can be not only alert() but any function you defined.. I still prefer to use events using simple onclick="" or even better would be to use a javascript framework like jQuery and use .click and so on.But an example with javascript in an url would be defining you own javascript function.. <html><head><script type="text/javascript">function displaymessage(){alert("Hello World!");}</script></head><body><a href="java script:displaymessage()">Click me</a><p>By pressing the link above, a function will be called. The function will alert a message.</p></body></html> So you'll get an HTML page, and when clicking the link, it will call the javascript function displaymessage() but in fact it's the same as setting a onclick event..I think this method shouldn't be used, instead use events and leave the links as they should be, hyperlinks, due to some browsers may have javascript turned off and the link won't do anything. Seems like the forum splits the word javascript to java script if you use it together with : so it should be "javascript+:" without the + Edited June 27, 2010 by Quatrux (see edit history) Share this post Link to post Share on other sites