自定义ie右键菜单
来源:互联网 发布:仙剑4mac版怎么破解 编辑:程序博客网 时间:2024/05/20 00:12
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>自定义鼠标右键弹出式菜单</title>
<style type="text/css">
<!--
.div1 { border-top:buttonface 1px solid;border-left:buttonface 1px solid;border-bottom:windowframe 1px solid;border-right:windowframe 1px solid;}
.div2 { border-top:window 1px solid;border-left:window 1px solid;border-bottom:buttonshadow 1px solid;border-right:buttonshadow 1px solid;}
.MouseOver {background-color:highlight;color:highlighttext;font-size: 12px;cursor:hand;font-size: 12px;}
.MouseOut {background-color:buttonface;color:buttontext;font-size: 12px;cursor:default;font-size: 12px;}
-->
</style>
<script language="javascript">
//弹出菜单
function PopupMouseRightButtonUpMenu()
{
//显示菜单
if(MouseMenu.style.visibility=='visible') MouseMenu.style.visibility='hidden';
//如果是链接、文本区或输入框,则显示IE菜单
if (event.srcElement.tagName=='A' || event.srcElement.tagName=='TEXTAREA' || event.srcElement.tagName=='INPUT' || document.selection.type!='None')
return true;
else
{
//防止菜单出格
if (event.clientX+150 > document.body.clientWidth) MouseMenu.style.left=event.clientX+document.body.scrollLeft-150;
else MouseMenu.style.left=event.clientX+document.body.scrollLeft;
if (event.clientY+DivH > document.body.clientHeight) MouseMenu.style.top=event.clientY+document.body.scrollTop-DivH;
else MouseMenu.style.top=event.clientY+document.body.scrollTop;
MouseMenu.style.visibility='visible';
}
//禁止IE菜单
return false;
}
//画出菜单,但不显示
function DrawMouseRightButtonUpMenu(){
DivH=2;
//oSelection = document.selection;
var HrStr='<tr><td align=/"center/" valign=/"middle/" height=/"2/"><TABLE border=/"0/" cellpadding=/"0/" cellspacing=/"0/" width=/"128/" height=/"2/"><tr><td height=/"1/" bgcolor=/"buttonshadow/"><//td><//tr><tr><td height=/"1/" bgcolor=/"buttonhighlight/"><//td><//tr><//TABLE><//td><//tr>';
var MenuItemStr1='<tr><td align=/"center/" valign=/"middle/" height=/"20/"><TABLE border=/"0/" cellpadding=/"0/" cellspacing=/"0/" width=/"132/"><tr><td valign=/"middle/" height=/"16/" class=/"MouseOut/" onMouseOver=/"this.className=/'MouseOver/'/" onMouseOut=/"this.className=/'MouseOut/'/" onclick=/"'
var MenuItemStr2="<//td><//tr><//TABLE><//td><//tr>";
var historyMenu=['window.history.back()/">后退','window.history.forward()/">前进'];
var SysMenu=['/">查找 <INPUT TYPE=/"text/" Size=/"10/" onkeypress=/"if (event.keyCode == 13) {MouseMenu.style.visibility=/'hidden/';var temp = this.value; this.value = /'/';return findInPage(temp)}/";/'>',
'document.execCommand(/'SelectAll/')/">全选',
'MouseMenu.style.visibility=/'hidden/';document.execCommand(/'SaveAs/',/'true/')/">另存为 ',
'location.replace(/'view-source:/'+location.href)/">查看源文件',
'MouseMenu.style.visibility=/'hidden/';window.print()/">打印',
'window.location.reload()/">刷新'];
var MenuStr='';
for(i=0;i<historyMenu.length;i++)
{
MenuStr+=MenuItemStr1+historyMenu[i]+MenuItemStr2;
DivH+=20;
}
MenuStr+=HrStr;
for(i=0;i<arguments.length;i++)
{
MenuStr+=MenuItemStr1+arguments[i]+MenuItemStr2;
DivH+=20;
}
if(arguments.length>0)
{
MenuStr+=HrStr;
DivH+=2;
}
for(i=0;i<SysMenu.length;i++)
{
MenuStr+=MenuItemStr1+SysMenu[i]+MenuItemStr2;
DivH+=20;
}
var aboutMenu=['MouseMenu.style.visibility=/'hidden/';alert(/'http:////www.playyuer.com//nmailto:playyuer@263.net/')">关于 ']
MenuStr+=HrStr;
for(i=0;i<aboutMenu.length;i++)
{
MenuStr+=MenuItemStr1+aboutMenu[i]+MenuItemStr2;
DivH+=20;
}
var MenuTop = '<DIV id=/"MouseMenu/" class=/"div1/" style=/"position:absolute; left:0px; top:0px; width=150;height='+DivH+'; z-index:1; visibility:hidden;/">/n' +
'<TABLE border=/"0/" cellpadding=/"0/" cellspacing=/"0/" class=/"div2/">/n' +
'<tr>/n' +
'<td bgcolor=/"' + MenuBarColor+ '/" width=/"50/" valign=/"bottom/" align=/"center/" bgcolor=/"buttonface/">/n' +
'<//td>/n'+
'<td bgcolor=/"buttonface/">/n'+
'<TABLE border=/"0/" cellpadding=/"0/" cellspacing=/"0/">';
var MenuBottom = '<//TABLE><//td><//tr><//TABLE><//DIV>';
document.write(MenuTop+MenuStr+MenuBottom);
//prompt('aa',MenuTop+MenuStr+MenuBottom)
document.body.oncontextmenu=new Function('return PopupMouseRightButtonUpMenu();');
document.body.onclick=new Function('if(event.srcElement.tagName !=/'INPUT/') MouseMenu.style.visibility=/'hidden/'');
document.body.onscroll=new Function('MouseMenu.style.visibility=/'hidden/';');
document.body.onselectstart=new Function('MouseMenu.style.visibility=/'hidden/';');
window.onresizestart=new Function('MouseMenu.style.visibility=/'hidden/';');
}
var NS4 = (document.layers);
var IE4 = (document.all);
var win = window;
var n = 0;
//查找字符串
function findInPage(str) {
var txt, i, found;
if (str == '')
return false;
if (NS4) {
if (!win.find(str))
while(win.find(str, false, true))
n++;
else
n++;
if (n == 0)
alert('文档搜索完毕。');
}
if (IE4) {
txt = win.document.body.createTextRange();
for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
txt.moveStart('character', 1);
txt.moveEnd('textedit');
}
if (found) {
txt.moveStart('character', -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;
}
else {
if (n > 0) {
n = 0;
findInPage(str);
}
else
alert('文档搜索完毕。');
}
}
return false;
}
</script>
</head>
<body>
自定义鼠标右键弹出式菜单
<a href=http://hsxixi.cnblogs.com>坐看云起Blog</a>
<SCRIPT LANGUAGE="JavaScript">
<!--
var MenuBarColor ='#6600FF';
DrawMouseRightButtonUpMenu();
//-->
</SCRIPT>
</body>
</html>
- 自定义ie右键菜单
- 实例解析自定义IE右键上下文菜单
- 给IE浏览器增加自定义右键菜单
- IE右键菜单
- 自定义网页右键菜单
- 自定义右键菜单
- 自定义网页右键菜单
- Flash8自定义右键菜单
- 自定义右键菜单
- 网页自定义右键菜单
- 自定义右键菜单
- 自定义右键菜单功能
- flex 自定义右键菜单
- flex自定义右键菜单
- Flex4自定义右键菜单
- Flex自定义右键菜单
- 右键自定义菜单
- Flex4 自定义右键菜单
- 计算机的世界是这样的。。。。
- 关于 Eclipse中运行Nutch No URLs to fetch的问题解决
- FlexBuilder 快捷键
- 在Windows下使用Python编程
- Git和Repo扫盲——如何取得Android源代码
- 自定义ie右键菜单
- jquery+ajax无刷新翻页
- JS-点击隐藏显示div里面的内容和改变左边icon
- 几种常见设计模式的使用
- 让浏览器弹出像FTP访问服务器一样的用户名和密码输入框
- 浅析:setsockopt()
- 一个ntohs函数的实现
- 敏捷开发中编写高质量Java代码
- ucenter 用户加密方式