A fine IE time saver


This trick allows to copy the url of a target image in a web page. You can do this for any anchor link by right-clicking and choosing Copy shortcut. This copies the target url in your clipboard. And if this link encloses an image, this copies the target url, regardless the image.

What now if what you want is the url of the image itself? When you right-click an image, there is no Copy image shortcut option to play with. This comes to me as a necessary time saver since I find myself linking to some image every time in the weblog, at work, and so on. And I believe this is probably the kind of things that you also do more often than not.

Without a Copy image shortcut option, I have to get right into the html source code, look for the text near the image, and hopefully will find it. All of this is not long, takes a minute, but is way unnecessary.

That's why I have built a small shortcut that adds itself in the context menu any time your right-click an image, whether it's embedded by an anchor or not. And this trick works for Internet Explorer only (and all web browsers based on the web browser control hopefully).

The general extension technique is detailed in this MSDN paper.

Here is what to do :

  1. Open the following registry key : HKEY_CURRENT_USER / Software / Microsoft / Internet Explorer / MenuExt
  2. Create a subkey named Copy image Shortcut (or whatever name you decide to put. That's the name of the context menu option)
  3. In this new subkey, change the default value and make it point to an external file we are going to create later. In my case I put this : c:\tmp\CopyLinkShortcut.html.
  4. In this new subkey, add a DWORD value called contexts, and assign it the value 2. This value tells Internet Explorer to add this menu option only when we right-click on an image.
  5. Create a new file, for instance c:\tmp\CopyLinkShortcut.html, and put the following content in it :
    <script language="javascript">
    var img = external.menuArguments.event.srcElement;
  6. Close all Internet Explorer sessions. Restart. You are done.

Please note the trick works even if the clipboard access is set to Disabled in the Internet Explorer options. That's because our external file is a local file, and hence security access does not apply.


Stephane Rodriguez- January 10, 2004.