[IE tip] Add "Copy Image Location" menu item

NetRyder

Tech Junkie
Joined
19 Apr 2002
Messages
13,256
Cross posting this from my blog...

As I may have mentioned earlier, I'm making it a point to use IE 7 as my primary browser, at least during the beta test period, so that I can report any issues that I find.

Since I've been using Firefox for such a long time, there was one little thing that was bugging me - IE does not include a context-menu item to quickly copy the location/URL of an image on a webpage. This is something I tend to use quite often (to post links to images in emails, IM messages, on forum threads etc.), and the multi-step process of selecting Properties, highlighting the image location and then copying it just wasn't cutting it.

So I posted a wish/suggestion on the beta newsgroups asking for such a context-menu item. Eric Lawrence from the IE team responded to my post and said it's possible to add something like this quite trivially using the MenuExt registry key. I looked up the MenuExt registry reference on MSDN, understood how it works, and wrote this quick little JavaScript blurb that adds a "Copy Image Location" item to the IE context menu. Note that this is not IE7-specific and will work on IE6 as well.

Here's how you do it. Copy the following piece of code into Notepad and save it as a HTML file to any location (I'll use C:\Windows\copyimageurl.html for this example):

Code:
<script language="JavaScript">
var image = external.menuArguments.event.srcElement;
clipboardData.setData("Text",image.src);
</script>

Then you need to create a registry key to point to this file:

1. Start>Run>regedit
2. Navigate to HKCU\Software\Microsoft\Internet Explorer\MenuExt
3. Create a new sub-key and call it "Copy Image Location" (this is the text that appears in the menu)
4. Set the "(Default)" string value to the location of the html file we created - C:\Windows\copyimageurl.html in this example.
5. In the same key, create a new DWORD value called "Contexts" and give it a value of 2 (this means that the menu item appears only when you right click an image)

That's it. Close any existing browser windows and when you open them back up, you should notice a new context-menu item that copies the image location to the clipboard.

Ah, that made life much easier. :)
 
Im still waiting for a "Open link in Firefox" option :p

Ill still do this one anyway...
 
Hehe, I don't have Firefox installed right now. I'll download it and try to write something. Shouldn't be too difficult. :)
 
Last edited:
Ok, here you go. Same basic concept.
Toss the code into an html file, create a new sub-key under MenuExt ("Open Link in Firefox"), and set the Default value to the path of the html file. This time you'll want to give the Contexts DWORD a hex value of 20 (that's decimal 32), so that it only appears when you right-click hyperlinks.

Code:
<script language="JavaScript"> 
var foo = new ActiveXObject("WScript.Shell"); 
foo.Run("Firefox " + external.menuArguments.event.srcElement); 
</script>
 
You know, this is actually fun to play with! Here are two more I thought of. Very simple, but quite handy - highlight text and search for it on Google or Dictionary.com.
I call the menu items "Google It!" and "Define It!" :D

Google It!
Code:
<script language="JavaScript">
open('http://dictionary.reference.com/search?q=' + external.menuArguments.document.selection.createRange().text);
</script>

Define It!
Code:
<script language="JavaScript">
open('http://www.google.com/search?q=' + external.menuArguments.document.selection.createRange().text);
</script>

You can add Wikipedia, Yahoo, or whatever else you want using the same syntax...even a mapping service to search for street addresses. This time, set the Contexts DWORD value to hex 10 (that's decimal 16) so that the items appear only when you right-click highlighted text.
 
Someone's bored. :rolleyes: :p


Seriously though, Good tips NetRyder. :D
 
NetRyder said:
create a new sub-key under MenuExt

I dont see that in my reg, is that a vista only feature?
 
zeke_mo said:
I dont see that in my reg, is that a vista only feature?
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt
If you don't see the MenuExt key, just create one. It probably gets created by the first menu extension that's added (mine was the "Export to Microsoft Excel" one created during the Office 2003 install). It's definitely not a Vista-specific feature though. :)
 
Nice work.

Is there any way to create a context menu in IE that would send an image to an external program?

For example, I right click on an image and select "Send to Photoshop"?

Thanks!
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back