文章来源:http://www.xhtmlhelp.net/javascript/12738.html

第一种:最笨的方法
把下列代码加入到<head>与</head>之间
<SCRIPT language=javascript>
function click() {
if (event.button==2) {
alert('网页教学网http://www.webjx.com')
}
}
document.onmousedown=click
</SCRIPT>

第二种:添加至收藏夹
<SCRIPT language=JavaScript><!--
function click() {
if (event.button==2) {window.external.addFavorite('http://www.webjx.com','网页教学网')}}
document.onmousedown=click
// --></SCRIPT>

第三种:使鼠标右键无响应,别人还以为自己的鼠标坏了!
把<BODY>改成<BODY oncontextmenu=self.event.returnValue=false>

第四种:最聪明的方法,自己定制鼠标的右键菜单,给访问者以全新的感受!
第一步:把代码加入到<head>与</head>之间
<style>
<!--
#ie5menu{
position:absolute;
width:200px;
border:2px solid black;
background-color:menu;
font-family:Verdana;
line-height:20px;
cursor:default;
visibility:hidden;
}
.menuitems{
padding-left:15px;
padding-right:15px;
}
-->
</style>
<script language="JavaScript1.2">
status bar
var display_url=0
function showmenuie5(){
var rightedge=document.body.clientWidth-event.clientX
var bottomedge=document.body.clientHeight-event.clientY
if (rightedge<ie5menu.offsetWidth)
ie5menu.style.left=document.body.scrollLeft+event.clientX-ie5menu.offsetWidth
else
ie5menu.style.left=document.body.scrollLeft+event.clientX
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")
window.location=event.srcElement.url
}
</script>
第二步:把下列代码加入到<body>与</body>之间
<!--[if IE]>
<div >
document.oncontextmenu=showmenuie5
if (document.all&&window.print)
document.body.onclick=hidemenuie5
</script>

相关文章:

  • 2021-05-16
  • 2022-12-23
  • 2022-12-23
  • 2022-02-17
  • 2022-12-23
  • 2021-06-25
  • 2021-11-09
  • 2021-12-27
猜你喜欢
  • 2021-07-12
  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
  • 2022-03-12
相关资源
相似解决方案