如何在asp.net页面上放置的控件上实现左右键菜单,同时
来源:互联网 发布:java中的返回值是什么 编辑:程序博客网 时间:2024/06/01 08:28
上文说到菜单被创建出来了,现在要说的是第二部分的:
(2),选择菜单,点击菜单
选择菜单和点击菜单实际上时鼠标的MouseMove和Click事件。在上文提到的menustyle里面,我是通过JavaScript提供的window.createPopup函数来实现弹出菜单,弹出菜单的内容为一个表格。在表格中的每一项都提供了MouseMove和Click事件。
在MouseMove事件发生的时候,我就让他显示出不同的风格。
当发生Click事件的时候,就调用函数fnclick,使之发生我们的需要的任务。现在具体来介绍menustyle()函数。
function menuStyle(){
if(window.navigator.appName == "Microsoft Internet Explorer" && window.navigator.appVersion.substring(window.navigator.appVersion.indexOf("MSIE") + 5, window.navigator.appVersion.indexOf("MSIE") + 8) >= 5.5)
isIe = 1;
else
isIe = 0;
if(isIe){
menuContent = '<table id="rightMenu" width="0" height="0" cellspacing="0" cellpadding="0" style="font:menu;color:menutext;"><tr height="1"><td style="background:black" colspan="4"></td></tr><tr height="10"><td style="background:black"></td><td style="background:Snow"><table cellspacing="0" cellpadding="0" nowrap style="font:menu;color:menutext;cursor:default;">'; //这一行是画了个表格,从下面开始,添加表格里面的项目,同时给出了MouseOver的风格等。最关键的一个地方是onClick事件发生调用的函数为parent.fnclickmenu,特别提醒的是调用的是父窗口的函数。
for(m=0;m<menuItems.length;m++){
if(menuItems[m][0] && menuItems[m][2])
menuContent += '<tr height="17" onMouseOver="this.style.background='#9999cc';this.style.color='menutext';" onMouseOut="this.style.background='Snow';this.style.color='menutext';" onClick="parent.fnclickmenu(''+menuItems[m][1]+'')"<td style="background:threedface" width="1" nowrap></td><td width="21" nowrap><img src="' + menuItems[m][2] + '"></td><td nowrap>' + menuItems[m][0] + '</td><td width="21" nowrap></td><td style="background:threedface" width="1" nowrap></td></tr>';
else if(menuItems[m][0])
menuContent += '<tr height="17" onMouseOver="this.style.background='#9999cc';this.style.color='menutext';" onMouseOut="this.style.background='Snow';this.style.color='menutext';" onClick="parent.fnclickmenu(''+menuItems[m][1]+'')"><td style="background:threedface" width="1" nowrap></td><td width="21" nowrap></td><td nowrap>' + menuItems[m][0] + '</td><td width="21" nowrap></td><td style="background:threedface" width="1" nowrap></td></tr>';
else
menuContent += '<tr><td colspan="5" height="4"></td></tr><tr><td colspan="5"><table cellspacing="0"><tr><td width="2" height="1"></td><td width="0" height="1" style="background:threedshadow"></td><td width="2" height="1"></td></tr><tr><td width="2" height="1"></td><td width="100%" height="1" style="background:threedhighlight"></td><td width="2" height="1"></td></tr></table></td></tr><tr><td colspan="5" height="3"></td></tr>';
}
menuContent += '</table></td><td style="background:threedshadow"></td><td style="background:threeddarkshadow"></td></tr><tr height="1"><td style="background:threedlightshadow"></td><td style="background:threedhighlight"></td><td style="background:threedface"></td><td style="background:threedshadow"></td><td style="background:threeddarkshadow"></td></tr><tr height="1"><td style="background:threedlightshadow"></td><td style="background:threedshadow" colspan="3"></td><td style="background:threeddarkshadow"></td></tr><tr height="1"><td style="background:threeddarkshadow" colspan="5"></td></tr></table>';
//下面就弹出了一个菜单。
menuPopup = window.createPopup();
//菜单里面的东西为上面画出的表格。
menuPopup.document.body.innerHTML = menuContent;
结合上文的ShowMenu(),函数,就明白了如何实现弹出菜单功能的方法了。在fnclickmenu函数中。你就可以轻松的加上你想处理的各种功能了。
各位看官,如果不明白还希望能够和我交流。Email:l_yx123@sina.com.cn
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>- 如何在asp.net页面上放置的控件上实现左右键菜单,同时
- 如何在asp.net页面上放置的控件上实现左右键菜单,同时
- 如何在asp.net页面上放置的控件上实现左右键菜单,同时对之操作(1)
- 如何在asp.net页面上放置的控件上实现左右键菜单,同时对之操作(2)
- 如何在asp.net页面上放置的控件上实现左右键菜单,同时对之操作(1)
- 如何在asp.net页面上放置的控件上实现左右键菜单,同时对之操作(2)
- 如何在asp.net页面上放置的控件上实现左右键菜单,同时对之操作
- 在控件上右键菜单的实现
- 在控件上右键菜单的实现
- 如何在控件上添加右键菜单
- VC中实现在指定控件上弹出右键菜单
- 如何在Asp.Net下遍历指定页面上的所有控件
- 实现Web页面上的右键快捷菜单
- 在DevExpress的treelist控件节点上实现右键弹出菜单项
- 应用程序上屏蔽FLASH控件的右键菜单并获得左键消息
- 应用程序上屏蔽FLASH控件的右键菜单并获得左键消息
- 如何在Qt的widget上右键显示菜单
- javascript中如何实现浏览器上的右键菜单
- NUnit 在VS.NET 2003上的插件.
- 使用VB.NET加密文件
- DataGrid在分页状态下删除纪录的问题
- vb.net 程序设计规范(1)
- vb.net程序设计规范(2)
- 如何在asp.net页面上放置的控件上实现左右键菜单,同时
- 美司法部开始调查雅虎Google测试性合作
- 设计模式之单件模式(Singleton Pattern )
- 转载:Java性能的优化(上)
- 利用数据集在水晶报表中显示图像的 .NET 程序教程
- Amazon的体系结构
- CE 报表应用服务器 9 与 CE 9 的主要区别
- 实例解析SOCKET编程模型(-)
- J2EE下使用AJAX(三) DWR