🤯 50% Off! 700+ courses, assessments, and books

Fun JavaScript Snippets

Sam Deering

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));