设为首页
加入收藏
帮助中心
首页 | 红盾通告 | 信息中心 | ASP技术 | 数据库 | 网页设计 | 网管专栏 | OICQ攻略 | 墨客频道 | 网站运营 |
当前位置:首页 >> 网页设计 >> HTML/CSS >> 正文
最新信息
·关于代码加密解密保护
·自动往下伸展开和收缩的动…
·地址栏图标及收藏栏图标
·页面进入和退出的特效
·网页是否被检索
·仿网易邮箱的登陆文本框样…
·巧用样式表,让文本框与按…
·CSS样式使图片虚线边框
·页面中点击鼠标右键---弹出…
·表格的折行处理
资料搜索
热点信息
·仿网易邮箱的登陆文本框样…
·无边框文本框
·CSS样式使图片虚线边框
·地址栏图标及收藏栏图标
·巧用样式表,让文本框与按…
·页面中点击鼠标右键---弹出…
·网页将不能被另存为
·绝对与浏览器边框无缝隙的…
·页面进入和退出的特效
·表格做流动分割线
推荐信息
·自动刷新页面
·定义本网页关键字
·网页将不能被另存为
·可以在收藏夹中显示出你的…
·容易控制的一个选项卡
·主页技巧27条
·绝对与浏览器边框无缝隙的…
·定制浏览器地址栏前的小图…


Google
 
页面中点击鼠标右键---弹出与windows界面相似的菜单
〖编辑:Cloudy | 浏览:人次〗

(下面的代码帖到记事本能直接运行查看)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns:MSHelp=http://msdn.microsoft.com/msHelp>
<HEAD>
<TITLE>oncontextmenu Event Sample</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-8859-1">
<META NAME="AUTHOR" CONTENT="InetSDK">
<META NAME="MS.LOCALE" CONTENT="EN-US">
<META NAME="ROBOTS" CONTENT="noindex">

<!--设置菜单的背景样式-->

<STYLE>
.menuItem {font-family:sans-serif;font-size:10pt;width:100;padding-left:20;
background-Color:menu;color:black}
.highlightItem {font-family:sans-serif;font-size:10pt;width:100;padding-left:20;
background-Color:highlight;color:white}
.clickableSpan {padding:4;width:500;background-Color:blue;color:white;border:5px gray solid}
</STYLE>

<SCRIPT>
//<!--

//弹出菜单:

function displayMenu() {
whichDiv=event.srcElement;
menu1.style.leftPos+=10;
menu1.style.posLeft=event.clientX;
menu1.style.posTop=event.clientY;
menu1.style.display="";
menu1.setCapture();
}

//高亮显示鼠标移上是菜单的背景
function switchMenu() {
el=event.srcElement;
if (el.className=="menuItem") {
el.className="highlightItem";
} else if (el.className=="highlightItem") {
el.className="menuItem";
}
}

//点击菜单相应项时触发相应的事件
function clickMenu() {
menu1.releaseCapture();
menu1.style.display="none";    //点击后隐藏菜单
el=event.srcElement;
if (el.id=="mnuRed") {
whichDiv.style.backgroundColor="red";
} else if (el.id=="mnuGreen") {          
whichDiv.style.backgroundColor="green";   //选择Green时背景变为绿色
} else if (el.id=="mnuBlue") {
whichDiv.style.backgroundColor="blue"; //选择blue时背景变为蓝色
} else if (el.id=="mnuYellow") {
whichDiv.style.backgroundColor="yellow"; //选择yellow时背景变为黄色

}
}

//-->
</SCRIPT>


<!-- SAMPLE_STYLE_START -->
<LINK REL="stylesheet" HREF="/workshop/basicSDKIE4.css" TYPE="text/css">
<!-- SAMPLE_STYLE_END -->
<LINK REL="stylesheet" TYPE="text/css" HREF="ms-help://Hx/HxRuntime/HxLink.css"><STYLE TYPE="text/css">
PRE.clsCode { font-size:110%; }
PRE.clsSyntax { font-size:100%; }
TD DIV.clsBeta { display:none;}
MSHelp\:link {
color:#0000ff;
text-decoration:underline;
cursor:hand;
hoverColor:#3366ff;
filterString: ;}
</STYLE>
</HEAD>
<!-- TOOLBAR_START -->
<!-- TOOLBAR_EXEMPT -->
<!--TOOLBAR_END-->

<BODY TOPMARGIN=0 LEFTMARGIN=0 BGPROPERTIES="FIXED" BGCOLOR="#FFFFFF"
LINK="#000000" VLINK="#808080" ALINK="#000000">
<BLOCKQUOTE CLASS="body">

<!-- CONTENTS_START -->
<H1>oncontextmenu Event Sample</H1>
<P>This sample shows how to use the <B>oncontextmenu</B> event handler, available in Microsoft&#174; Internet Explorer 5 and later, to display both standard and custom context menus and prevent context menus from displaying. Experiment with each of the following boxes to see how you can apply different methods either to display or to inhibit context menus. Each box provides instructions for you to follow.
</P>

<SPAN class="clickableSpan">
1. The default context menu always displays when you right-click in this box.
<b><br>Code: </b>
//no code necessary
</SPAN><br><br>

<SPAN class="clickableSpan" oncontextmenu="return event.ctrlKey">
2. The default context menu displays only if you right-click in this box while holding down the Ctrl key. This is useful for developing and debugging purposes.
<b><br>Code: </b>
oncontextmenu="return event.ctrlKey"
</SPAN><br><br>

<SPAN class="clickableSpan" oncontextmenu="return false">
3. A context menu never displays when you right-click in this box.
<b><br>Code: </b>
oncontextmenu="return false"
</SPAN><br><br>

<SPAN class="clickableSpan" oncontextmenu="displayMenu();return false">
4. A custom context menu displays when you right-click in this box.
<b><br>Code: </b>
oncontextmenu="showMenu();return false;"
</SPAN><br><br>

<SPAN class="clickableSpan" oncontextmenu="if (!event.ctrlKey){displayMenu();return false;}">
5. A custom menu displays when you right-click in this box. If you right-click while holding down the Ctrl key, the default context menu displays.
<b><br>Code: </b>
oncontextmenu="if (!event.ctrlKey){displayMenu();return false;}"
</SPAN><br>

<div id=menu1 onclick="clickMenu()" onmouseover="switchMenu()" onmouseout="switchMenu()" style="position:absolute;display:none;width:100;background-Color:menu; border: outset 3px gray">
<div class="menuItem" id=mnuRed>Red</div>
<div class="menuItem" id=mnuGreen>Green</div>
<div class="menuItem" id=mnuBlue>Blue</div>
<div class="menuItem" id=mnuYellow>Yellow</div>
</div>


<!-- CONTENTS_END -->
<!-- START_PAGE_FOOTER -->
<BR><BR><BR>
<MSHelp:link xmlns:MSHelp="http://msdn.microsoft.com/mshelp" keywords="msdn_copyright" TABINDEX="0">&copy; 2003 Microsoft Corporation. All rights reserved.</MSHelp:link>.
<!-- END_PAGE_FOOTER -->
</BLOCKQUOTE>
</BODY>
</HTML>


录入时间:2006-08-01 16:50:49 [打印本页] [关闭窗口] [返回顶部]
特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。

Copyright © 2006-2014 0733168.Com Inc All Rights Reserved
关于我们 | 广告合作 | 联系我们 | 法律声明 | 友情链接 | 意见反馈
本站所收录信息、社区话题、及本站所做之广告均属其个人行为,与本站立场无关
湘ICP备06008436号