1.文件AddScript.reg添加IE右键菜单
REGEDIT4
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt]
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\◎ 收藏此页到【博客园网摘】]
@="http://home.cnblogs.com/wz/rightclick/"
2.文件Remove.reg删除IE右键菜单
REGEDIT4
[-HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\◎ 收藏此页到【博客园网摘】]
3.IE浏览器输入http://home.cnblogs.com/wz/rightclick/,查看源码
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="JavaScript">
//如果是拓展菜单事件,则执行以下代码
if (external.menuArguments) {
var parentwin = external.menuArguments;
if (parentwin.document.selection) {
var sel = parentwin.document.selection.createRange().text;
}
if (!sel) {
var sel = '';
}
//获得右键页面的URL
var url = parentwin.document.URL;
//获得右键页面的title
var title = parentwin.document.title;
var i = 0;
//如果鼠标在A标签上
if (parentwin.event.srcElement.tagName == "A") {
url = parentwin.event.srcElement.getAttribute("HREF");
title = parentwin.event.srcElement.innerText;
}
//如果鼠标在IMG标签上
if (parentwin.event.srcElement.tagName == "IMG") {
url = parentwin.event.srcElement.getAttribute("SRC");
if (parentwin.event.srcElement.getAttribute("ALT") != null && parentwin.event.srcElement.getAttribute("ALT") != "") {
title = parentwin.event.srcElement.getAttribute("ALT");
}
i = 1
}
//打开新的IE窗口
void (window.open('http://wz.cnblogs.com/create?t=' + encodeURIComponent(title) + '&u=' + encodeURIComponent(url) + '&c=' + encodeURIComponent(sel) + '&i=' + i, '_blank', 'scrollbars=auto,width=460,height=353,left=100,top=50,status=yes,resizable=yes'))
} else {
//返回
history.go(-1);
}
</script>
</html>
--OVER