|
||
| Inside Technique : Extending the Browser : Adding Context When you are using the browser, you may have noticed there are quite a few different context menus displayed based on the selection or where the mouse is when clicked. For example, if you registered the extension yourself, the context menu for annotate is always available. If you registered it through our site, you will only see it when text is selected. In this section, we explain how to control when your menu option is displayed with the contexts registry key. The availability of the extension is defined by a DWORD registry entry "Contexts". Adding this is as simple as expanding the key representing your menu option and selecting new DWORD from the edit menu. Give the name of this value Contexts. The value itself is a number representing the contexts when the option should be available. The following contexts are defined in Internet Explorer:
For the annotate extension, set the value of the Scripting the context menuYour extension also has access to what context menu was used to call your extension. This allows you to customize your extension based on where the user is when they choose the extension. The type of context menu is exposed through the event object's type property. The type property returns a string that corresponds to the context menu:
For example, in our Remember Me tool, we have a switch statement for handling the different types of context menus:
You have now learned the basics for creating your own extension. In the next section, we explain how to add a user-interface to your extensions. Page 1:Extending the Browser © 1997-2000 InsideDHTML.com, LLC. All rights reserved. |