标签:content arc word order name strong on() uri .text
其实就是类似当安装完 Flashget 后 Internet Explorer 的右键多了“使用网际快车下载”的选项一样,现在我们的需求是:当我们在图片右键时出现“复制图像地址”的选项。
其实很简单,先把下列代码存为 abc.reg 并导入:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\复制图像地址(&Z)]
@="C:\\CopyImageUrl.htm"
"contexts"=dword:00000002
并把下列代码存为 C:\CopyImageUrl.htm:
<script language="javascript" defer>
var Elem=external.menuArguments.event.srcElement;
var imgUrl=‘‘;
if(Elem.tagName==‘IMG‘) imgUrl=Elem.src;
else if(Elem.tagName==‘A‘){
var cElem=Elem.children;
if(cElem.length){
for(i=0; i<=cElem.length-1; i++){
if(cElem[i].tagName==‘IMG‘) imgUrl=cElem[i].src;
break;
}
}
}
if(imgUrl) clipboardData.setData(‘text‘,imgUrl)
</script>
重启你的浏览器就可以用了。
要注意几点:
快捷键
根据个人经验,熟练地使用这个功能,至少可以让操作快上 80% 的时间,甚至 Flashget 默认也没设置这个人性化的功能,遗憾。不过我们完全可以修改之,嘿嘿!
可选项
Value Constant_Name Description
0x01 CONTEXT_MENU_DEFAULT Shown on all context menus.
0x02 CONTEXT_MENU_IMAGE Context menu of images only.
0x04 CONTEXT_MENU_CONTROL Context menu of form controls only.
0x08 CONTEXT_MENU_TABLE Context menu of tables only.
0x10 CONTEXT_MENU_TEXTSELECT Context menu of selected text only, including images in a selected region.
0x20 CONTEXT_MENU_ANCHOR Context menu of links only. Does not include linked images or image maps.
0x40 CONTEXT_MENU_UNKNOWN Right-click on none of the above.
多种值综合应用是“或”的关系,比如需要在默认和连接时右键时显示,则 contexts=0x21;想单独在图片上显示,则 contexts=0x02 了。
举例
下面例子可以将页面在新窗口显示:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Show in New Window]
@="file://c:\\example2.htm"
"Contexts"=dword:00000001
c:\example2.htm
<SCRIPT LANGUAGE="JavaScript" defer>
window.open(external.menuArguments.location.href);
</SCRIPT>
下面例子可以将选中文字变为大写:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\My &Menu Item]
@="file://c:\myscript.htm"
"Contexts"=dword:00000001
c:\myscript.htm
<SCRIPT LANGUAGE="JavaScript" defer>
var parentwin = external.menuArguments;
var doc = parentwin.document;
var sel = doc.selection;
var rng = sel.createRange();
var str = new String(rng.text);
if(str.length != 0) rng.text = str.toUpperCase();
</SCRIPT>
效果
删除
将下列代码存为 unreg.reg 并导入就可以了:
Windows Registry Editor Version 5.00
[-HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\复制图像地址(&Z)]
参考
About the Browser
http://windowssdk.msdn.microsoft.com/en-gb/library/ms629731.aspx
Adding Entries to the Standard Context Menu
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/ext/tutorials/context.asp
如何在右键菜单添加“拷贝图像地址”
http://forum.maxthon.com/index.php?showtopic=13228&st=0&p=87259
目前自己用的:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt]
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\复制图像地址(&Z)]
@="D:\\Afly\\CopyImg.html"
"contexts"=dword:00000002
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\打开图像(&W)]
@="D:\\Afly\\OpenImg.html"
"contexts"=dword:00000002
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\播放该音乐(&M)]
@="D:\\Afly\\OpenMusic.html"
"Contexts"=dword:00000022
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\查询单词(&D)]
@="D:\\Afly\\OpenDict.html"
"contexts"=dword:00000030
<script language="javascript" defer>
var rng = external.menuArguments.document.selection.createRange();
var str = new String(rng.text);
if(str.length == 0) str=external.menuArguments.event.srcElement.innerText;
window.open("http://sh.dict.cn/search/?q="+str,"_search");
</script>
<script language="javascript" defer>
var Elem=external.menuArguments.event.srcElement;
var imgUrl=‘‘;
var rng = external.menuArguments.document.selection.createRange();
var str = new String(rng.text);
if(Elem.tagName==‘IMG‘) imgUrl=Elem.src;
else if(Elem.tagName==‘A‘){
var cElem=Elem.children;
if(cElem.length){
for(i=0; i<=cElem.length-1; i++){
if(cElem[i].tagName==‘IMG‘) imgUrl=cElem[i].src;
break;
}
}
}
else if(str.length != 0){
imgUrl = str;
}
if(imgUrl) eval(‘wi‘+‘ndow.op‘+‘en(imgUrl,"_blank")‘);
</script>
<script language="javascript" defer>
var Elem=external.menuArguments.event.srcElement;
var MusicUrl="";
if(Elem.tagName==‘IMG‘){
MusicUrl=Elem.parentElement.href;
}
if(Elem.tagName==‘A‘){
MusicUrl=Elem.href;
}
window.open("file://D:/Afly/Player.html?"+MusicUrl,‘_blank‘,‘status=no,resizable=yes,width=350,height=250,left=250,top=130‘);
//encodeURIComponent(MusicUrl)
</script>
<html>
<head>
<script language="javascript">
var url = document.location.search.substr(1);
window.onload=function() {
if(url)WMP.URL=url;WMP.play();
}
</script>
</head>
<body style="margin:0;padding:0">
<div id="MusicBox" class="SideContent">
<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="WMP" width="100%" height="100%">
<param name="URL" value="" />
<param name="autoStart" value="1" />
<param name="playCount" value="3" />
<param name="rate" value="1" />
<param name="enabled" value="1" />
<param name="invokeURLs" value="-1" />
<param name="volume" value="50" />
<param name="mute" value="0" />
<param name="uiMode" value="full" />
<param name="stretchToFit" value="0" />
<param name="windowlessVideo" value="1" />
<param name="enableContextMenu" value="1" />
<param name="fullScreen" value="0" />
<param name="enableErrorDialogs" value="0" />
</object>
</div>
</body>
</html>
标签:content arc word order name strong on() uri .text
原文地址:http://www.cnblogs.com/developer-ios/p/6551355.html