While researching a way to provide bookmarks inside of a multi-server web application, I came across something I already knew about, but actually hadn't ever done in a production environment--the context menu extension.
Three Steps:
- Create the menu item
- Implement the event
- Do something cool
Step 1
This is as simple as creating the Name of the menu in the Registry
HKLU/Software/Microsoft/Internet Explorer/MenuExt/<Menu Item>
Name your menu item and set the following
- (default) - Location of script
- Contexts - What type of stuff can respond to your menu item using the following bitmask values:
- Default (0x1)
- Images (0x2)
- Controls (0x4)
- Tables (0x8)
- Text Selection (0x10)
- Anchor (0x20)
- Flags (optional)-I didn't use it, so I won't explain it.
Step 2
This is where the script comes in. I used a much improved script, but this should give you an idea of how it works. Create an HTML page that only contains the following and link to it as described above.
<script>
var w = window.external.menuArguments;
var l = w.document.activeElement;
alert('Bookmarking ' + l);
</script>
Step 3
Do something cool. This is where I will leave it up to you. Personally, the script creates a favorite in my profile as well as hands it off to a web service that puts it in a database for me. This way I can have my links all going to one place. I'll extend this at some point, but I'll never have to worry about bookmarking a link on one machine and then losing it.