Skip to main content

Fun JavaScript Snippets

By Sam Deering



Free JavaScript Book!

Write powerful, clean and maintainable JavaScript.

RRP $11.95

Hi guys, just a few JavaScript snippets I thought I would share with you.

JavaScript Space Mouse Script
Now you can play game on any web page, just copy and paste the javascript code given below in the url bar and hit enter. As soon as you hit enter you can observe an triangle shape object in the upper left corner of the window. Navigate it with the help of W, A and D keys and fire using Spacebar.


JavaScript Edit Page Directly Script
You easily edit any web page using this javascript. But when you refresh the page changes are lost.

javascript: document.body.contentEditable = 'true'; document.designMode = 'on'; void 0

JavaScript Infinite Alert Boxes Script
As soon as you run this javascript a infinite loop of alert boxes will open which cannot be stopped until you restart your web browser. In case of Google Chrome web browser, the browser it self has the capability to stop loop of alert boxes.
Warning: Obviously before running this close other tabs you have open (save your work!)

javascript:while(1){alert('Restart your brower to close this box!')}

JavaScript URL Calculator Script
You can also use javascript for calculation purposes. Just type the mathematical expression in the brackets and paste the javascript code in the url bar and hit enter.

javascript: alert(4+5+6+7+(3*10));

Example: display your phone number:

javascript: alert('0'+(658*6)+''+(231228/9));

Related Articles

Sam Deering has 15+ years of programming and website development experience. He was a website consultant at Console, ABC News, Flight Centre, Sapient Nitro, and the QLD Government and runs a tech blog with over 1 million views per month. Currently, Sam is the Founder of Crypto News, Australia.

New books out now!

Learn the basics of programming with the web's most popular language - JavaScript

A practical guide to leading radical innovation and growth.

Integromat Tower Ad