How to Run JavaScript From Favorites

How to Run JavaScript From Favorites thumbnail
Add point-and-click JavaScript to your favorites using bookmarklets.

In less than a minute, you can add powerful, interactive JavaScript code to your Internet Explorer Favorites menu. Once inside the menu, it stays and waits for you to click it. Clicking the code's icon runs the JavaScript. Tiny pieces of JavaScript code added to browsers are called "bookmarklets." Depending on the JavaScript code you use, bookmarklets added to favorites can do anything from changing the way a Web page looks to searching the Web using your favorite search engine.

Instructions

    • 1

      Launch Internet Explorer and click the "Favorites" button near the top of the browser. The Favorites menu opens.

    • 2

      Click "Add to Favorites and type "Test Bookmarklet" in the "Name" text box. Select the "Create In" drop-down menu, and then click "Favorites."

    • 3

      Select "Add" to create your new JavaScript bookmarklet in your Favorites folder.

    • 4

      Click the "Favorites" button again and locate the favorite you added. Right-click the favorite, and then click "Properties." The Properties window opens.

    • 5

      Type the following JavaScript code into the "URL" text box."

      javascript:alert("testing")

      This creates a short JavaScript statement that displays the JavaScript alert box.

    • 6

      Click "OK, and then click "Yes" to close the Properties window. The JavaScript bookmarklet is now ready to use.

    • 7

      Select the Favorites button to open the Favorites menu. Click your new bookmarklet. The JavaScript runs and executes the code you entered. A JavaScript-alert box appears and displays the word "testing."

Tips & Warnings

  • This example illustrates the use of Favorites to run a simple JavaScript function. Create more complex JavaScript code if you like, and add it to Internet Explorer, using the steps described.

  • Remember to add the word "javascript" followed by a colon to the beginning of your JavaScript code. The JavaScript will not run if you do not do this.

Related Searches:

References

Resources

  • Photo Credit Pixland/Pixland/Getty Images

Comments

Related Ads

Featured