.

定义右键菜单代码
分类:电脑知识 发表于:2010-04-08 13:16:57 评论(2)


=====================

CSS部分:

=====================

<style type="text/css">

#ie5menu{

display:inline;

float:left;

font-family: Verdana;

color:#000000;

}

.skin0 {

position:absolute;

width:160px;

border:1px solid #C0C0C0;

background-color:#FFFFFF;

font-family:Verdana;

font-size:9pt;

line-height:20px;

cursor:default;

visibility:hidden;

padding:5px;

}

.skin1 {

cursor:default;

font:menutext;

position:absolute;

text-align:center;

font-family: Arial, Helvetica, sans-serif;

font-size:9pt;

width:160px;

background-color:#ccc;

visibility:hidden;

border:2 outset buttonhighlight;

}

.menuitems {width:150px;padding-left:20px;}

</style>

=====================

JS部分:

=====================

<script language="javascript">

var menuskin = "skin0"; // skin0, or skin1

var display_url = 0; // Show URLs in status bar?

function showmenuie() {

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 hidemenuie() {

ie5menu.style.visibility = "hidden";

}

function highlightie() {

if (event.srcElement.className == "menuitems") {

event.srcElement.style.backgroundColor = "#0066CC";

event.srcElement.style.color = "#fff";

if (display_url)

window.status = event.srcElement.url;

}

}

function lowlightie() {

if (event.srcElement.className == "menuitems") {

event.srcElement.style.backgroundColor = "";

event.srcElement.style.color = "#333";

window.status = "";

}

}

function jumptoie() {

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>

=====================

右键部分:

=====================

<div id="ie5menu" onmouseover="highlightie()" onmouseout="lowlightie()">    欢迎光临阿和个人网站

<hr color="#C0C0C0" width="150" size="1">

<div class="menuitems" url="index.htm" onclick="jumptoie();">1. 阿和小院</div>

<div class="menuitems" url="blog.asp" onclick="jumptoie();">2. 阿和博客</div>

<div class="menuitems" url="gb.asp" onclick="jumptoie();">3. 阿和留言本</div>

<hr color="#C0C0C0" width="150" size="1">

<div class="menuitems" onclick="showAbout();">‖阿和档案‖</div>

<hr color="#C0C0C0" width="150" size="1">

<div class="menuitems" onclick="javascript:window.location.reload()">※刷新※</div>

</div>

<script language="JavaScript" type="text/javascript">

if (document.all && window.print) {

ie5menu.className = menuskin;

document.oncontextmenu = showmenuie;

document.body.onclick = hidemenuie;

}

</script>

  
邮箱: 密码:
  • Lvtu 六韬三略 (2010-04-09 21:39:03)
    真郁闷呢!还以为你帮我弄好了呢! 看什么看呀?你的站没法COPY呢。。。 呵呵~~ 得之,我幸;失之,我命。如是而已!
    • 阿和 博主 (2010-04-09 22:59:59)
      嘿嘿。。所以特别预留了个网页可以COPY的。。