SiteExperts.com Logo Home | Community | Developer's Paradise | Jobs
User Groups | Site Tools | Site Information | Search

Inside Technique : Custom IE Context Menus
By HJ Hornbeck

the introduction

I have three reasons for writing this:

  • First, adding entries to the context menus can be a powerful tool. You could validate a web page's HTML syntax, with one click of the mouse. You could tweak a webpage's look by adding cascading style sheet commands, with one click. Want the URL of that background image without seeing any source code? Custom context menus can help.
  • Second, I have never seen any good tutorials with good examples on adding your own entries. Microsoft does provide a half-decent reference, and provides some good samples to examine (the IE4 PowerToys, or IE5's Web Accessories). Another article on SiteExperts also tried this, but they don't have as many examples. In short, there's been very little interest in the subject.
  • Finally, this article looks good on a resume :-)

I should also mention a similar idea: "Bookmarklets". Bookmarklets take advantage of the ability to use Javascript (or any other scripting language) from inside an anchor. They are stored with your bookmarks, or added to your "links" or "personal" toolbar, and can accomplish a lot of what the context menu entries can. They are also less restrictive of what browsers they will work in. Unfortunately, Bookmarklets have size restrictions and are not context-sensitive. If you are still interested in them, visit www.Bookmarklets.com.

The bad news begins here. Adding a context menu is only possible in Internet Explorer, and only in version 4 or later. In addition, you need to be running Windows 95, Windows 98, or Windows NT 4. Although these samples were only tested in Windows 98, they should work with no problems on the other operating systems.

This tutorial assumes you are comfortable with JavaScript and the Windows registry. While we expect you to be familiar with JavaScript, if you want to learn more about the registry, check out the registry FAQ at www.regedit.com.

I have separated this article into two parts - a tutorial that shows you how to create your own custom extensions, and a samples page with over a dozen samples. Enjoy!

Page 1:Custom IE Context Menus
Page 2:Tutorial
Page 3:Samples