“Copy as Text Link” and “Copy as Image Link” Blogging Tools
Justin of JustInsomnia had a great idea for a FireFox plug in:
I want to be able to copy a quote and its URL at the same time, without having to so much as think about it. To do so, I wrote my first Firefox extension, which I opted to name the somewhat homely, Copy as HTML Link.
So he created Copy as HTML Link for Firefox and generously shared his moment with wp-hackers Subscribers .
The plugin looks good and he did a really good job documenting it (THIS IS RARE!):
I must say that since I’ve started using this method, it’s been a quite a time saver. This was a GREAT idea. Inspired! So, if you have FireFox, please head on over there and get that plug-in!
Ah, but here’s the fly in the ointment and the sand in my… socks: A Firefox plugin won’t work for Maxthon!!!! (
) or Internet Explorer!
You see, Firefox just doesn’t do it for me.
Opera comes darn close to being right, but I like the extra usability features in Maxthon.
So, I thought… Hey… I could do that for Maxthon and IE AND I could do it all from a BATCH file!
So, here it is…
Run this Batch file and you will have installed on your system, two new menu items. When you highlight text, you’ll have an option to “Copy as Link” and when an image is right clicked, you will get an option to “Copy Image as Link”. Hopefully I’ve chosen hotkeys that will work well for you… If not, you can change them in RegEdit at HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\
BTW EVERY image and link up to this point in this post was created using this tool. Man, Good idea Justin!
Also - If you find that IE is prompting you asking for permissions to open the links, please post a comment and I’ll show how to fix that. I’ve gotten that message on other things I’ve like this I’ve created and know how to get past it. I’ve disabled that workaround on this computer and I am not getting that “Are you sure” message. So these menu items should be safe. ALSO, some popup blockers may block these items. You might have to add localhost as a site that is allowed to show popups in your particular popup blocker. Let me know if you have any problems.
Here’s the download: http://www.TheCodeCave.com/downloads/batch/AddCopyAsLink.bat
Here is the source:
-
@echo Off
-
:: Implements "Copy * as Link" menu items in IE and Maxthon
-
:: Written by Brian Layman
-
:: Visit me at: http://www.TheCodeCave.com
-
:: Version 0.1
-
:: Update Url: http://www.thecodecave.com/?p=152
-
:: Inspired by Justin’s Firefox Plubin
-
:: Found at: http://justinsomnia.org/2006/05/copy-as-html-link-for-firefox/
-
-
:: Create file for the Copy Text as Link
-
echo ^>%windir%\web\copytextaslink.htm
-
echo ^<script language="JavaScript">>>%windir%\web\copytextaslink.htm
-
echo var parentwin = external.menuArguments;>>%windir%\web\copytextaslink.htm
-
echo var doc = parentwin.document;>>%windir%\web\copytextaslink.htm
-
echo var sel = doc.selection;>>%windir%\web\copytextaslink.htm
-
echo var rng = sel.createRange();>>%windir%\web\copytextaslink.htm
-
echo var str = new String(rng.text);>>%windir%\web\copytextaslink.htm
-
echo window.clipboardData.setData(‘Text’, ‘^<a href="’ + parentwin.location + ‘"^>’ + str + ‘^</a^>’);>>%windir%\web\copytextaslink.htm
-
echo ^</SCRIPT^>>>%windir%\web\copytextaslink.htm
-
echo ^</HTML^>>>%windir%\web\copytextaslink.htm
-
-
:: Create the menu context.
-
reg ADD "HKCU\Software\Microsoft\Internet Explorer\MenuExt\Copy Te&xt as Link" /ve /t REG_SZ /d "%WINDIR%\web\copytextaslink.htm" /f
-
reg ADD "HKCU\Software\Microsoft\Internet Explorer\MenuExt\Copy Te&xt as Link" /v Contexts /t REG_DWORD /d 16 /f
-
-
:: Create file for Copy Image as Link
-
echo ^<HTML^>>%windir%\web\copyimageaslink.htm
-
echo ^<SCRIPT LANGUAGE="JavaScript" defer^>>>%windir%\web\copyimageaslink.htm
-
echo var parentwin = external.menuArguments;>>%windir%\web\copyimageaslink.htm
-
echo var doc = parentwin.document;>>%windir%\web\copyimageaslink.htm
-
echo var w;>>%windir%\web\copyimageaslink.htm
-
echo var h;>>%windir%\web\copyimageaslink.htm
-
echo var sel = doc.selection;>>%windir%\web\copyimageaslink.htm
-
echo var rng = sel.createRange();>>%windir%\web\copyimageaslink.htm
-
echo var str = new String(rng.text);>>%windir%\web\copyimageaslink.htm
-
echo if ( parentwin.event.srcElement.tagName == "IMG" )>>%windir%\web\copyimageaslink.htm
-
echo {>>%windir%\web\copyimageaslink.htm
-
echo h = parentwin.event.srcElement.height;>>%windir%\web\copyimageaslink.htm
-
echo w = parentwin.event.srcElement.width;>>%windir%\web\copyimageaslink.htm
-
echo window.clipboardData.setData(‘Text’, ‘^<a href="’ + parentwin.location + ‘"^>^<img src="’ + parentwin.event.srcElement.href + ‘" Width = "’ + w + ‘" Height = "’ + h + ‘" alt="Click to go to the original site."/^>^</a^>’);>>%windir%\web\copyimageaslink.htm
-
echo }>>%windir%\web\copyimageaslink.htm
-
echo else>>%windir%\web\copyimageaslink.htm
-
echo alert ("Incompatible element. Select either just an image or just text.");>>%windir%\web\copyimageaslink.htm
-
echo ^</SCRIPT^>>>%windir%\web\copyimageaslink.htm
-
echo ^</HTML^>>>%windir%\web\copyimageaslink.htm
-
-
:: Create the menu context.
-
reg ADD "HKCU\Software\Microsoft\Internet Explorer\MenuExt\Copy Image as Lin&k" /ve /t REG_SZ /d "%WINDIR%\web\copyimageaslink.htm" /f
-
reg ADD "HKCU\Software\Microsoft\Internet Explorer\MenuExt\Copy Image as Lin&k" /v Contexts /t REG_DWORD /d 2 /f
-
:: Done
-
cls
-
Echo.
-
Echo The Right-Click + "Copy * as Link" features have been added to Maxthon
-
Echo and all other IE based browsers.
-
Echo.
-
Echo Please close and restart all browsers to complete the install.
-
Echo.
-
Echo Thank you for using this tool from TheCodeCave.com.
-
Echo.
-
Echo - Brian
-
Echo.
-
Echo.
-
Echo.
-
pause
Just let me know if you have any issues… It’s been working great for me!

















[...] Brian Layman has created a version of Copy as HTML Link and imgTag for IE. Excellent. Trackback Thursday, May 25, 20067:12pm [...]
Pingback by Copy as HTML Link for Firefox - Justinsomnia — May 26, 2006 @ 7:49 pm
[...] Inspiriert durch diese Firefox-Erweiterung ist übrigens mittlerweile auch für den Internet Explorer eine ähnliche “Erweiterung” entstanden, die Brian Layman unter http://www.thecodecave.com (englisch) bereitgestellt hat. [...]
Pingback by Speed-Blogging mit Copy as HTML Link [hirnrinde.de - was in unseren Köpfen herumspukt…] — May 28, 2006 @ 7:55 am
[...] IE下也有人做出了如下的插件:Copy as HTML Link and imgTag for Internet Explorer。 var tabPane1 = new WebFXTabPane( document.getElementById( "tab-pane-1" ) ); [...]
Pingback by 两个FF下的小插件 at E-space — May 28, 2006 @ 9:32 am
I have no idea what Maxthon is - I'll take a look... But since I work with Mac OS X, there fortunately isn't an Internet Exploder anymore.
Comment by Julian Schrader — May 30, 2006 @ 4:03 pm
[...] Usually when I post something technical, I include a detailed rambling explaniation of how it does what it does. In the post "Copy as Text Link" and "Copy as Image Link" Blogging Tools" I created a batch file that did some neat stuff. But I didn't give a full explaination of the details. Now I will. [...]
Pingback by The Code Cave — June 2, 2006 @ 12:48 am
[...] # A couple redirects I want to keep from when I’ve tried different permalink formats Redirect /2006/05/26/copy-as-text-link-and-copy-as-image-link-blogging-tools/ http://www.thecodecave.com/?p=152 Redirect /Article68 http://www.thecodecave.com/article68 Redirect /2006/05/28/lg-vx5200-lg-vx6000-lg-vx7000-lg-vx8100-stuff/ http://www.thecodecave.com/article113 [...]
Pingback by The Code Cave — June 7, 2006 @ 10:12 am
[...] This HTML file builds on top of the work that I did on with the Copy as Text Link tool referenced elsewhere on this site. However, this routine processes the currently active webpage/frame and generates a report of the Forms and fields on that page. For each form it shows its name, action and then list the inputs on that form. For each input, it shows its name and value. From this information, you can see what is being tracked between pages on a website. You could also use this information to debug an entry form you are creating. It could also be used to generate the form submission information that will be generated by a certain action so that it can be repeated programmatically in the future. [...]
Pingback by The Code Cave — July 19, 2006 @ 12:03 pm
[...] Note: These links were created with the Copy Text as Link tool for IE. [...]
Pingback by The Code Cave — December 19, 2006 @ 1:33 am