Advertisment

Extend IE with Web Accessories

author-image
PCQ Bureau
New Update

The early days of the war over the Internet saw two sides-Microsoft's IE and Netscape's Navigator. It was Navigator that ruled the world, until IE crept up and almost wiped it out. Others such as Opera were also there, but had little impact. 

Advertisment

IE reigned supreme till FireFox came along. FireFox is free, fast and fun and has slowly begun to eat into IE's share. It offers users many features, such as tabbed browsing and skinning. And one of the best things about FireFox is that one can make it more powerful by installing 'Extensions'. The extensions can be downloaded from its site

(www.mozilla.org/products/firefox/).

However, IE still has some aces up its sleeve. In fact, the ability to extend its power in a similar fashion as FireFox has been in it from the fourth generation (or should it be version?). This ability is called 'Browser Extensions' and adds many capabilities under this one umbrella.

Direct Hit!
Applies to: Web developers/users
USP: Add zoom in/out for images, highlight all instances of a word, in your IE
Links:

http://msdn.microsoft.com 
Advertisment

Browser Extensions refer to the technologies that allow a developer to extend the use of IE by writing some very simple code. The extensions may be applied to create custom toolbars, explorer bars, desk bands and context menu entries that let you perform a custom task. The last in this list is what is known as 'Web Accessories'.

Web Accessories let you extend IE by adding custom actions to different locations and events. For instance, one could add 'Zoom In' and 'Zoom Out' when the user right clicks on an image on a Web page. 

To create these context menus, certain information is required. There are a few requirements that need to be fulfilled before the item you are adding starts working in IE. The first thing to do is add an entry in the registry that points to the new Web Accessory. This is achieved by making a new entry in

HKEY_CURRENT_USER \Software\Microsoft\InternetExplorer\MenuExt\. For instance, if you want to add 'Zoom In' you will add an entry as: HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Zoom In. Note that you can also add an ampersand (&) anywhere in the name to make it a shortcut key. That is, if in the above you named it as 'Zoom &In', the 'I' (you will see it as 'Zoom In') will be a shortcut key for the new entry in the menu.

Advertisment

Hilite All menu item is added in the context menu of a text selection

Now once you have made this entry there are two other things you need to do. The first is to set the default key in the entry to point to the file that contains the script that you want to execute when the event is fired. For instance, you can point the default key to 'C:\Windows\Web\ZoomIn.htm'. 

The second and very important thing is to add a new binary value under this new item and rename it to 'Contexts'. This is the key that specifies the Context in which the menu entry is to appear. The table below enlists different values that you can enter in this key.

Advertisment

Remember that you can perform a logical OR with these values to make the entry appear in more than one type. For example, to get the menu entry for images and text selections, the decimal value is 18. 

Let's now take a look at creating a simple Web Accessory that is displayed in the context menu when a user selects some text. The accessory allows the user to highlight all instances of the selected word in the current document. This is similar to the 'Context Highlight' and 'Advanced Highlighter' extensions for FireFox.



For this, first create an entry in the registry as: HKCU\Software\Microsoft\Internet Explorer\MenuExt\Hilite &All...\. In the default key, enter 'C:\WINDOWS\Web\hlword.htm'. Create a new binary key, rename it to 'Contexts' and put the value as '1100' (Decimal 16). 

Value

(in Decimal)
Context
1 Default

(Everywhere)
2 Images
4 Controls
8 Tables
16 Text

Selection
32 Anchor
Advertisment

Then create an HTML file in C:\WINDOWS\Web\hlword.htm. The contents of the file will be as follows.









There are some important items to note in this script. The first is the 'defer' parameter to the

Advertisment