Pages

Tuesday, January 24, 2012

Run Javascript Code through the URL Bar

/*Below is the format for the Javascript insertion*/

javascript: /*JAVASCRIPT CODE HERE*/ void(0);


Directions

  1. Type your Javascript code into a text document
  2. Open up any web browser.
  3. Go to any website.
  4. Replace the URL for the site with javascript:
  5. Paste your code at the end of javascript:
  6. Finally, add a space followed by void(0); to the end of the URL
  7. Hit [Enter] or click "Go!" to run the script

Example #1: A Name Prompt

A simple prompt for your name and then it outputs HI to you with the name you entered.

javascript:
 var name= prompt("What is your name?");
 alert("HI, "+name); void(0);


Example #2: Edit Any Webpage

This second one can allow you to edit webpages like a Word document (only for you, though). You can take pictures (PrntScr) to show your friends what you "saw" written on a website.

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

No comments:

Post a Comment