前两天在网上发现一个很好的站点,是用来做资料收藏的(http://wolf.360doc.com)。
这个网站提供了这么一个功能,可以直接将你选中的文字收藏起来,当时觉得很神奇的。后来研究了一下,发现用JavaScript和注册表脚本就可以实现这样的功能。
右键收藏页面代码如下(我的收藏页面命名为rightClick.jsp):
复制代码 代码如下:
<html>
<scriptLANGUAGE="JavaScript">
if(external.menuArguments)
{
varselText="";
varstrTitle=escape(external.menuArguments.document.title);
varstrURL=escape(external.menuArguments.location.href);
vardoc=external.menuArguments.document;
if((doc.selection.type=="None")||(doc.selection.type=="none"))
{
alert("请选中网页上欲保存的文字和图片后再收藏!");
}
else
{
selText=doc.selection.createRange().text;
if(selText=="")
{
alert("请选中网页上欲保存的文字和图片后再收藏!");
}
else
{
external.menuArguments.document.execCommand("Copy");
varobjChild;//Window
varreWork=newRegExp('object','gi');//Regularexpression
objChild=window.open("SaveMenu.jsp?title="+strTitle+"&url="+strURL,"objChild","toolbar=no,menubar=no,resizable=yes,location=no,status=yes,z-look=yes,alwaysRaised=yes,scrollbars=no");
if(!reWork.test(String(objChild)))
alert("文章收藏页面被拦截!rn请设定你安装的拦截弹出窗口软件,使当前页面不被拦截!");
}
}
}
</script>
</html>
文本显示页面代码如下(我的收藏页面命名为SaveMenu.jsp):
复制代码 代码如下:
<HTML>
<HEAD>
<title>网络收藏</title>
<scriptlanguage="JavaScript">
<>
</script>
</HEAD>
<bodyvLink="#261cdc"link="#261cdc"leftMargin="0"topMargin="5"onload="setTimeout('Preloader();',1000);">
<ptitle="网络收藏的文本框">网络收藏的文本框</p>
<textareaname="TextBox"id="TextBox"style="height:300px;width:100%;"></textarea>
</body>
</HTML>
注册表脚本如下:
复制代码 代码如下:
WindowsRegistryEditorVersion5.00
[HKEY_CURRENT_USERSoftwareMicrosoftInternetExplorerMenuExt]
[HKEY_CURRENT_USERSoftwareMicrosoftInternetExplorerMenuExtLocalhostTest]
@="http://10.1.1.19:8080/test/rightClick.jsp"
大家如果有兴趣可以自己试试!