[JavaScript] Ie 右键菜单取网页信息
实现功能:在IE中右键菜单中取出网页中的相关信息。
1、建立调用的.htm文件,内容如下:
<script type="text/javascript">
function Invoke()
{
//得到父窗口对象
var parentWin = external.menuArguments;
var winURL = parentWin.document.URL; //网页URL
//得到父窗口对象
//var srcEvent = external.menuArguments.event;
//var EventElement =external.menuArguments.document.elementFromPoint ( srcEvent.clientX, srcEvent.clientY );
//var winURL=EventElement.href;//网页中所点的链结URL
}
</script>
<html><body onload="Invoke();"></body></html>
function Invoke()
{
//得到父窗口对象
var parentWin = external.menuArguments;
var winURL = parentWin.document.URL; //网页URL
//得到父窗口对象
//var srcEvent = external.menuArguments.event;
//var EventElement =external.menuArguments.document.elementFromPoint ( srcEvent.clientX, srcEvent.clientY );
//var winURL=EventElement.href;//网页中所点的链结URL
}
</script>
<html><body onload="Invoke();"></body></html>
2、建立注册表文件.reg,来调用.htm文件 内容如下:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt]
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Modify Title]
@="D:\\Work\\#.htm"
"contexts"=dword:000000D1 //注册取网页信息
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Modify Title2]
@="D:\\Work\\#.htm"
"contexts"=dword:00000022 //注册取选中链结
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt]
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Modify Title]
@="D:\\Work\\#.htm"
"contexts"=dword:000000D1 //注册取网页信息
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Modify Title2]
@="D:\\Work\\#.htm"
"contexts"=dword:00000022 //注册取选中链结