web前端

位置:IT落伍者 >> web前端 >> 浏览文章

实现Web页面上的右键快捷菜单


发布日期:2018年05月05日
 
实现Web页面上的右键快捷菜单

样式代码

<style type=text/css>

body{font: pt 宋体; margintop: px ; color: red; background: #ffffff}

a{ font: pt 宋体; cursor: hand; fontsize: pt ; color: blue; textdecoration: none }

a:active{ font: pt 宋体; cursor: hand; color: #FF }

:hover{ font: pt 宋体; cursor: hand; color: #FF}

box{ font: pt 宋体; position: absolute; background: LightGrey; }

</style>

html代码如下

<table id=itemopen class=box >

<tr>

<td>弹出菜单</td>

</tr>

<tr>

<td><a cc>Erickson的专栏</a></td>

</tr>

<tr>

<td><a cc>CSDN</a></td>

</tr>

<tr>

<td><a cc>Google 搜索</a></td>

</tr>

<tr>

<td><a cc>搜狐</a></td>

</tr>

<tr>

<td><a cc>Yahoo</a></td>

</tr>

<tr>

<td><a cc> 网站</a></td>

</tr>

<tr>

<td><a cc>新浪网体育</a></td>

</tr>

</table>

脚本代码

右击鼠标显示快捷菜单

<script language=JavaScript>

documentonmousedown = function popUp() {

menu = emopen

if (eventbutton == ) {

newX = windoweventx + documentbodyscrollLeft

newY = windoweventy + documentbodyscrollTop

menustyledisplay =

menustylepixelLeft = newX

menustylepixelTop = newY

}

else if (eventbutton == )

{

menustyledisplay = none

}

}

</script>

屏蔽IE默认的WinForm快捷菜单

<script language=JavaScript>

var message=;

function clickIE()

{

if (documentall)

{

(message);

return false;

}

}

function clickNS(e)

{

if (documentlayers||(documentgetElementById&&!documentall))

{

if (ewhich==)

{

newX = windoweventx + documentbodyscrollLeft

newY = windoweventy + documentbodyscrollTop

menu = emopen

if ( menustyledisplay == )

{

menustyledisplay = none

}

else

{

menustyledisplay =

}

menustylepixelLeft = newX

menustylepixelTop = newY

}

if (ewhich==)

{

(message);

return false;

}

}

}

if (documentlayers)

{

documentcaptureEvents(EventMOUSEDOWN);

documentonmousedown=clickNS;

}

else

{

documentonmouseup=clickNS;documentoncontextmenu=clickIE;

}

documentoncontextmenu=new Function(return false)

</script>

上一篇:嵌入式Web视频点播系统实现方法

下一篇:WebSphere MQ传输环境搭建和测试