Adding Entries to the Standard Context Menu

This tutorial explains how to add an entry into the standard context menus in Windows Internet Explorer that executes a script specified by a URL.

Requirements and Dependencies

Developers who want to add entries to the standard context menus in Internet Explorer must be familiar with the registry. Developers should also be familiar with context menus. For more information about context menus, see the Windows Shell API documentation in the Windows Software Development Kit (SDK).

The implementation described here is valid for Microsoft Internet Explorer 4.0 or later. This feature is not available in earlier versions of Internet Explorer.

Implementation Steps

The following steps are required to add an entry into the standard context menus in Internet Explorer.

  1. Create a new key, using the text you want displayed in the context menu as the name, under:

    HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt

    The result should look like:

    HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\<Menu Text>

    <Menu Text> should be replaced with the text that you want displayed in the context menu. The name can include an ampersand (&) character, which will cause the character that follows to be underlined and used as a shortcut key.

  2. Set the default value of the key to the URL of the page that contains the script you want the context menu entry to execute. This script can obtain the parent window object, the screen where the context menu item was executed, from the menuArguments property of the external object.
  3. Optional. Create a binary value, Contexts, under:

    HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\<Menu Text>

    The result should look like:

    HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\<Menu Text>\Contexts

    Set the value of Contexts to indicate which contexts your entry should appear in the standard context menu by using a bit mask consisting of the logical OR of the following values:

    ContextValue
    Default0x1
    Images0x2
    Controls0x4
    Tables0x8
    Text selection0x10
    Anchor0x20

    For example, if you want your context menu entry to appear in the default context menu and when the context is a text selection, set the value of Contexts to 0x11.

  4. Optional. Create a DWORD value, Flags, under:

    HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\<Menu Text>

    The result should look like:

    HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\<Menu Text>\Flags

    Set the value of Flags to 0x1 to make the script run just as if it had been called through the showModalDialog method. Unlike the showModalDialog method, the script can access the window object of the parent window from the menuArguments property of the external object.

Strings stored inside a resource can be referenced by providing the path to the resource and reference identification in the format "path, resource_id". For example, if you wanted to use string resource 123 in Example.dll, you would use "Example.dll, 123".

Related Topics

Tags :


Community Content

James Woodall
Multi Level Internet Explorer Context Menu

Is it possible to add a multi level context menu item to IE? [I want it badly :( ]

I have same question. Also, is there a way to enable/disable the menu item with script (without going thru the Internet Explorer Add-on business)?

[Noelle Mallory - MSFT] Please post questions to the MSDN Forums at http://forums.microsoft.com/msdn. You will likely get a quicker response through the forum than through the Community Content.

[EricLaw - MSFT] No, you cannot nest menus in IE7. In IE8, you can create Activities rather than using MenuExt, and you get a form of nesting for free.


[Petry] A contextmenu can open a contextmenu new version of itself with level expanded.

John Sudds
MenuExt Tutorial from Raymond Chen

Here's a quick walkthrough to help you get started with custom menu extensions:

http://blogs.msdn.com/oldnewthing/archive/2004/05/24/140283.aspx

Tags : dhtml

EricLaw-MSFT
Tables Context
Note: The "Tables" context is never used.
Tags :

Wang Yuxi
How can I keep the plugin script don't close.

I would like to asign an event handler to an element of the document currently open in IE.

And I write the handler in the plugin script.

in the script I assign the handler to the element of document currently opened,

after that ,the script close . so the computer can't not find the handler in the memory.

How can I keep the script alive , or keep the handler alive in memory?

Tags :

Page view tracker