点击右键就弹出一个菜单
来源:互联网 发布:淘宝买瓷砖靠谱吗 编辑:程序博客网 时间:2024/04/30 15:16
第一步:把下面代码放到<head></head>中(这里可以修改菜单的样式)。
<style>
<!--
.skin0{
position:absolute;
width:200px;
border:2px solid black;
background-color:menu;
font-family:Verdana;
line-height:20px;
cursor:default;
visibility:hidden;
}
.skin1{
cursor: default;
font: menutext;
position: absolute;
width: 165px;
background-color: menu;
border: 1 solid buttonface;
visibility:hidden;
border: 2 outset buttonhighlight;
}
.menuitems{
padding-left:15px;
padding-right:10px;
}
-->
</style>
第二步:下面代码放到:<body></body>间
<script language="JavaScript1.2">
//set the skin of the menu (0 or 1, with 1 rendering a default Windows menu like skin)
var menuskin=1
//set this variable to 1 if you wish the URLs of the highlighted menu to be displayed in the status bar
var display_url=0
function showmenuie5(){
//Find out how close the mouse is to the corner of the window
var rightedge=document.body.clientWidth-event.clientX
var bottomedge=document.body.clientHeight-event.clientY
//if the horizontal distance isn"t enough to accomodate the width of the context menu
if (rightedge<ie5menu.offsetWidth)
//move the horizontal position of the menu to the left by it"s width
ie5menu.style.left=document.body.scrollLeft+event.clientX-ie5menu.offsetWidth
else
//position the horizontal position of the menu where the mouse was clicked
ie5menu.style.left=document.body.scrollLeft+event.clientX
//same concept with the vertical position
if (bottomedge<ie5menu.offsetHeight)
ie5menu.style.top=document.body.scrollTop+event.clientY-ie5menu.offsetHeight
else
ie5menu.style.top=document.body.scrollTop+event.clientY
ie5menu.style.visibility="visible"
return false
}
function hidemenuie5(){
ie5menu.style.visibility="hidden"
}
function highlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor="highlight"
event.srcElement.style.color="white"
if (display_url==1)
window.status=event.srcElement.url
}
}
function lowlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor=""
event.srcElement.style.color="black"
window.status=""
}
}
function jumptoie5(){
if (event.srcElement.className=="menuitems"){
if (event.srcElement.getAttribute("target")!=null)
window.open(event.srcElement.url,event.srcElement.getAttribute("target"))
else
window.location=event.srcElement.url
}
}
</script>
<!--[if IE]>
<div id="ie5menu" class="skin0" onMouseover="highlightie5()" onMouseout="lowlightie5()" onClick="jumptoie5()">
<div class="menuitems" url="http://www.chinabs.net">★中国BS网★</div>
<div class="menuitems" url="http://www.sohu.com" target="_blank">搜狐搜索引擎</div>
<div class="menuitems" url="http://www.fanso.com">化云坊Fanso</div>
<div class="menuitems" url="http://www.163.com">网易搜索引擎</div>
<div class="menuitems" url="http://www.chinafootball.com">中国足球新闻网</div>
<div class="menuitems" url="http://www.365fm.com">联想网站</div>
<![endif]-->
<script language="JavaScript1.2">
if (document.all&&window.print){
if (menuskin==0)
ie5menu.className="skin0"
else
ie5menu.className="skin1"
document.oncontextmenu=showmenuie5
document.body.onclick=hidemenuie5
}
</script>
说明:注意修改链接。
- 点击右键就弹出一个菜单
- 点击右键就弹出一个菜单
- .NET 点击右键弹出菜单怎么做
- JTable中点击鼠标右键弹出菜单
- JQ实现右键点击弹出菜单
- Jquery鼠标右键点击弹出菜单
- JTable上点击右键并弹出菜单的实现
- 给JList中的Item添加右键点击弹出菜单事件
- CMyRichEditCtrl 与 CMyRichEditView 增加右键点击弹出菜单功能
- 屏蔽VC对话框中点击FLASH弹出的右键菜单
- winform 右键点击行时选中行,并弹出操作菜单
- 如何实现点击一个下拉菜单的选项就弹出不同的输入框或者下拉菜单
- java右键弹出菜单
- 动态弹出右键菜单
- 对话框弹出右键菜单
- 右键弹出菜单
- 控件右键弹出菜单
- 右键弹出菜单
- ini文件操作类
- 1.习惯的力量:35岁以前养成好习惯
- Excel操作类C#版
- 解决局域网IP冲突的问题
- 3.35岁以前成功必须戒除的9大恶习
- 点击右键就弹出一个菜单
- Excel操作类C#版2
- 虚拟主机IIS防范入侵常见问答
- 今天开始参加ORACLE PERFORMANCE TUNING 原厂培训.
- C++文件操作
- web开发常用js小技巧
- 如何取消连接服务器时"记住密码"?!
- 解决FCKeditor2.6上传时的各种问题
- 在网页中自己创建右键菜单