Quick & dirty way to run snippets of JavaScript anywhere

Ever wanted to run a snippet of JavaScript on a browser that doesn’t support a console in order to debug something? (for instance, IE6, Opera etc)
You probably know about Firebug Lite, but this either requires you to already have the bookmarklet, or in…


This content originally appeared on Lea Verou’s blog and was authored by Lea Verou

Ever wanted to run a snippet of JavaScript on a browser that doesn’t support a console in order to debug something? (for instance, IE6, Opera etc)

You probably know about Firebug Lite, but this either requires you to already have the bookmarklet, or include the script in the page. Although Firebug Lite is a great tool for more in depth debugging, it can be tedious for simple tasks (eg. “What’s the value of that property?”).

Fortunately, there is a simpler way. Do you remember the 2000 era and the javascript: URIs? Did you know that they also work from the address bar of any javascript-capable browser?

For instance, to find out the value of the global variable foo, you just type in the address bar javascript:alert(foo). You can write any code you wish after the javascript: part, as long as you write it properly to fit in one line.

Of course these URIs are a no-no for websites, but they can be handy for simple debugging in browsers that don’t support a console. ;)


This content originally appeared on Lea Verou’s blog and was authored by Lea Verou


Print Share Comment Cite Upload Translate Updates
APA

Lea Verou | Sciencx (2009-02-23T00:00:00+00:00) Quick & dirty way to run snippets of JavaScript anywhere. Retrieved from https://www.scien.cx/2009/02/23/quick-dirty-way-to-run-snippets-of-javascript-anywhere/

MLA
" » Quick & dirty way to run snippets of JavaScript anywhere." Lea Verou | Sciencx - Monday February 23, 2009, https://www.scien.cx/2009/02/23/quick-dirty-way-to-run-snippets-of-javascript-anywhere/
HARVARD
Lea Verou | Sciencx Monday February 23, 2009 » Quick & dirty way to run snippets of JavaScript anywhere., viewed ,<https://www.scien.cx/2009/02/23/quick-dirty-way-to-run-snippets-of-javascript-anywhere/>
VANCOUVER
Lea Verou | Sciencx - » Quick & dirty way to run snippets of JavaScript anywhere. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2009/02/23/quick-dirty-way-to-run-snippets-of-javascript-anywhere/
CHICAGO
" » Quick & dirty way to run snippets of JavaScript anywhere." Lea Verou | Sciencx - Accessed . https://www.scien.cx/2009/02/23/quick-dirty-way-to-run-snippets-of-javascript-anywhere/
IEEE
" » Quick & dirty way to run snippets of JavaScript anywhere." Lea Verou | Sciencx [Online]. Available: https://www.scien.cx/2009/02/23/quick-dirty-way-to-run-snippets-of-javascript-anywhere/. [Accessed: ]
rf:citation
» Quick & dirty way to run snippets of JavaScript anywhere | Lea Verou | Sciencx | https://www.scien.cx/2009/02/23/quick-dirty-way-to-run-snippets-of-javascript-anywhere/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.