[asp.net]网摘功能核心代码

本文介绍如何通过修改注册表实现浏览器右键菜单的自定义扩展,将选择的文本和链接快速发送到本地服务器进行处理。具体步骤包括创建注册表文件以添加菜单项、编写JavaScript代码捕获用户选择的内容及链接,以及在服务器端使用ASP.NET接收并处理这些数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一.写入注册表:
注册表文件:myreg.reg
内容:
REGEDIT4

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt]

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\加入我的网摘]
@="http://localhost/paper/rightclick.aspx"
二.删除以上操作:
文件名:Removemylreg.reg
内容:
REGEDIT4

[-HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\加入我的网摘]
三.在rightClick.aspx页面Html视图代码(vb代码为空)

<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 = '';
 }
 
 var url = parentwin.location.href;
 var title = parentwin.document.title;
 
 if (parentwin.event.srcElement.tagName == "A") {
  url = parentwin.event.srcElement.getAttribute("HREF");
  title = parentwin.event.srcElement.innerText;
 }
 void(window.open('http://localhost/Paper/index.aspx?t='+escape(title)+'&u='+escape(url)+'&c='+escape(sel),'_blank','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'))
} else {
 history.go(-1);
}
 </script>
在页面index.aspx里用Request.接收参数:t,u,,c再对其做处理,加入数据库.
如:   TextBox1.Text = Request.QueryString("t")
        TextBox2.Text  = Request.QueryString("u")
        TextBox3.Text  = Request.QueryString("c")
再对其做其它数据处理.

注意:index.aspx中Html, Page要加validateRequest=false属性.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值