spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column35


Creating Bookmarklets

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

As you already know, any hypertext link can be used in the form of a bookmark. The same rule applies to javascript: links, so you can actually create a bookmark that executes JavaScript code -- a bookmarklet. The following link displays an alert box and loads a Web page: Doc JavaScript.

If you're running Windows, right-click the link and select "Add Bookmark" (Navigator) or "Add to Favorites..." (Internet Explorer). If you're working on a Macintosh, hold the mouse button over the link until the menu appears, and create a bookmark. Due to a bug in the Macintosh version of Navigator, the bookmark's name may not show up properly. Rather than using the link's text as the name of the bookmark, the browser uses the URL for some reason. The specific bookmark can be edited by pressing Option+B (Bookmarks), selecting the desired bookmark, and then pressing Option+I (Get Info).

There are other ways to create bookmarks. In Navigator, open the Bookmarks window, and select the "New Bookmark..." option from the File menu. Then enter the desired name and URL for the bookmark. In Internet Explorer you will need to do some hacking. Locate the Favorites folder, and create a new file for the desired bookmark. We suggest that you stick to the standard "Add Bookmark" or "Add to Favorites..." option.

Executing JavaScript from a bookmark is great, but running a script from a permanent button is even better. By dragging a javascript: link to Navigator's Personal Toolbar or Internet Explorer's Links bar, you can present a JavaScript-powered button in your browser. You can add a button to Navigator's Personal Toolbar by creating a bookmark in its folder. For more information, refer to Netscape's JavaScript Guide.

Note that the Macintosh version of Navigator 4.5 features a Personal Toolbar, but previous versions do not. You should also know that the Links bar in the Macintosh version of Internet Explorer 4.0x causes some trouble, so you may find it difficult to use.

When you trigger a bookmarklet, you are actually running a script on the current page. Therefore, you cannot use a bookmarklet to access properties of a document in another window, belonging to a different site. These are simply security precautions that are typical to JavaScript.

http://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint


Created: February 1, 1999
Revised: February 1, 1999

URL: http://www.webreference.com/js/column35/creating.html