我在网上下了一个IE自定义右键菜单的JS代码menu0.js
// JavaScript Documentvar strMenu = "<div id=\"menu\" class=\"clsMenu\" onMouseover=\"highlight()\" onMouseout=\"lowlight()\">"
strMenu += "<div class=\"menuitems\" onClick=\"javascript:history.back()\">·µ»Ø</div>"
strMenu += "<div class=\"menuitems\" onClick=\"javascript:history.forward()\">Ç°½ø</div>"
strMenu += "<div class=\"menuitems\" onClick=\"javascript:location.reload()\">Ë¢ÐÂ</div>"
strMenu += "<div class=\"menuitems\" onClick=\"javascript:print()\">´òÓ¡</div>"strMenu += "<hr color=#999999 size=1>"
strMenu += "<div class=\"menuitems\" onClick=\"javascript:location.href='index.html'\">ϵͳÊ×Ò³</div>"
strMenu += "<div class=\"menuitems\" onClick=\"javascript:location.href='map.html'\">ϵͳ°ïÖú</div>"
//strMenu += "<div class=\"menuitems\" onClick=\"javascript:location.href='feedback.html'\">D??¡é¡¤¡ä¨¤?</div>"
//strMenu += "<div class=\"menuitems\" onClick=\"javascript:location.href='job.html'\">3???¨®¡é2?</a></div>"strMenu += "<div class=\"menuitems\" onClick=\"javascript:location.href='mailto:[email protected]'\">ÁªÏµÎÒÃÇ</a></div>"
strMenu += "<div class=\"menuitems\" onClick=\"javascript:location.href='law.html'\">Í˳öϵͳ</a></div>"
strMenu += "</div>"function ie() {
if (navigator.appName=="Microsoft Internet Explorer") {
return true;
} else {
return false;
}}function showmenu(){
if (ie()){
var rightedge=document.body.clientWidth-event.clientX
var bottomedge=document.body.clientHeight-event.clientY
if (rightedge<menu.offsetWidth)
menu.style.left=document.body.scrollLeft+event.clientX-menu.offsetWidth
else
menu.style.left=document.body.scrollLeft+event.clientX
if (bottomedge<menu.offsetHeight)
menu.style.top=document.body.scrollTop+event.clientY-menu.offsetHeight
else
menu.style.top=document.body.scrollTop+event.clientY menu.style.visibility="visible"
}
return false
}
function hidemenu(){
if (ie()) menu.style.visibility="hidden"
}
function highlight(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor="#FFD112"
event.srcElement.style.color="#000000"
}}
function lowlight(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor=""
event.srcElement.style.color="menutext"
}}if (ie()) document.write (strMenu);
document.oncontextmenu= showmenu
document.body.onclick= hidemenu
在如下一个HTML文件中调用,能正常显示并工作:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0031)http://www.hnjk.com.cn/map.html -->
<HTML><HEAD><TITLE></TITLE><LINK
href="main.css" type=text/css rel=stylesheet>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.3790.2817" name=GENERATOR></HEAD>
<BODY>
<SCRIPT language=JavaScript src="menu0.js">
</SCRIPT>
</BODY></HTML>main.css文件如下:
INPUT {
BORDER-TOP-WIDTH: 1px; PADDING-RIGHT: 1px; PADDING-LEFT: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 9pt; BORDER-LEFT-COLOR: #cccccc; BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: #cccccc; PADDING-BOTTOM: 1px; BORDER-TOP-COLOR: #cccccc; PADDING-TOP: 1px; FONT-FAMILY: ËÎÌå, Arial, Helvetica; HEIGHT: 18px; BACKGROUND-COLOR: #b0b2a2; BORDER-RIGHT-WIDTH: 1px; BORDER-RIGHT-COLOR: #cccccc
}
BODY {
SCROLLBAR-HIGHLIGHT-COLOR: buttonface; SCROLLBAR-SHADOW-COLOR: buttonface; SCROLLBAR-3DLIGHT-COLOR: buttonhighlight; SCROLLBAR-TRACK-COLOR: #eeeeee; SCROLLBAR-DARKSHADOW-COLOR: buttonshadow; font-color: #000066
}
.p10 {
FONT-SIZE: 10.5pt
}
.p9 {
FONT-SIZE: 9pt; PADDING-BOTTOM: 5px; LINE-HEIGHT: 150%; PADDING-TOP: 5px
}
.text {
FONT-SIZE: 9pt; FILTER: DropShadow(Color=#f5f5f5, OffX=1, OffY=1, Positive=1)
}
TD.menu {
BACKGROUND: #7d86aa
}
TD {
FONT-SIZE: 9pt; LINE-HEIGHT: 150%
}
.clsMenu {
BORDER-RIGHT: buttonhighlight 1px outset; BORDER-TOP: buttonhighlight 1px outset; VISIBILITY: hidden; BORDER-LEFT: buttonhighlight 1px outset; WIDTH: 100px; CURSOR: default; COLOR: #000000; BORDER-BOTTOM: buttonhighlight 1px outset; POSITION: absolute; BACKGROUND-COLOR: #f5f5f5
}
.menuitems {
PADDING-RIGHT: 10px; PADDING-LEFT: 20px; FONT-SIZE: 12px; COLOR: #333333; LINE-HEIGHT: 18px
}
.form1 {
FONT-SIZE: 9pt; BORDER-BOTTOM: #cccccc 1px solid
}
.form2 {
FONT-SIZE: 9pt; BORDER-BOTTOM: #999999 1px solid
}
.form3 {
BORDER-RIGHT: #999999 1px solid; FONT-SIZE: 9pt
}
.form4 {
BORDER-TOP: #cccccc 1px solid; FONT-SIZE: 9pt; BORDER-BOTTOM: #cccccc 1px solid
}
.form5 {
BORDER-TOP: #cccccc 1px solid; FONT-SIZE: 9pt
}
.form6 {
FONT-SIZE: 10.5pt; BORDER-BOTTOM: #999999 1px solid
}
.IN {
BORDER-TOP-WIDTH: 1px; PADDING-RIGHT: 1px; PADDING-LEFT: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 9pt; BORDER-LEFT-COLOR: #cccccc; BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: #cccccc; PADDING-BOTTOM: 1px; BORDER-TOP-COLOR: #cccccc; PADDING-TOP: 1px; FONT-FAMILY: ËÎÌå, Arial, Helvetica; HEIGHT: 18px; BACKGROUND-COLOR: #ffffff; BORDER-RIGHT-WIDTH: 1px; BORDER-RIGHT-COLOR: #cccccc
}
.form {
BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; FONT-SIZE: 9pt; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid; BACKGROUND-COLOR: white
}可是不知道为什么我一放到aspx页面中照上面的方式调用就不能正常显示了
郁闷啊不知道我讲清楚没
请高手们解答一下
帮帮偶..
在此感谢大家了
// JavaScript Documentvar strMenu = "<div id=\"menu\" class=\"clsMenu\" onMouseover=\"highlight()\" onMouseout=\"lowlight()\">"
strMenu += "<div class=\"menuitems\" onClick=\"javascript:history.back()\">·µ»Ø</div>"
strMenu += "<div class=\"menuitems\" onClick=\"javascript:history.forward()\">Ç°½ø</div>"
strMenu += "<div class=\"menuitems\" onClick=\"javascript:location.reload()\">Ë¢ÐÂ</div>"
strMenu += "<div class=\"menuitems\" onClick=\"javascript:print()\">´òÓ¡</div>"strMenu += "<hr color=#999999 size=1>"
strMenu += "<div class=\"menuitems\" onClick=\"javascript:location.href='index.html'\">ϵͳÊ×Ò³</div>"
strMenu += "<div class=\"menuitems\" onClick=\"javascript:location.href='map.html'\">ϵͳ°ïÖú</div>"
//strMenu += "<div class=\"menuitems\" onClick=\"javascript:location.href='feedback.html'\">D??¡é¡¤¡ä¨¤?</div>"
//strMenu += "<div class=\"menuitems\" onClick=\"javascript:location.href='job.html'\">3???¨®¡é2?</a></div>"strMenu += "<div class=\"menuitems\" onClick=\"javascript:location.href='mailto:[email protected]'\">ÁªÏµÎÒÃÇ</a></div>"
strMenu += "<div class=\"menuitems\" onClick=\"javascript:location.href='law.html'\">Í˳öϵͳ</a></div>"
strMenu += "</div>"function ie() {
if (navigator.appName=="Microsoft Internet Explorer") {
return true;
} else {
return false;
}}function showmenu(){
if (ie()){
var rightedge=document.body.clientWidth-event.clientX
var bottomedge=document.body.clientHeight-event.clientY
if (rightedge<menu.offsetWidth)
menu.style.left=document.body.scrollLeft+event.clientX-menu.offsetWidth
else
menu.style.left=document.body.scrollLeft+event.clientX
if (bottomedge<menu.offsetHeight)
menu.style.top=document.body.scrollTop+event.clientY-menu.offsetHeight
else
menu.style.top=document.body.scrollTop+event.clientY menu.style.visibility="visible"
}
return false
}
function hidemenu(){
if (ie()) menu.style.visibility="hidden"
}
function highlight(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor="#FFD112"
event.srcElement.style.color="#000000"
}}
function lowlight(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor=""
event.srcElement.style.color="menutext"
}}if (ie()) document.write (strMenu);
document.oncontextmenu= showmenu
document.body.onclick= hidemenu
在如下一个HTML文件中调用,能正常显示并工作:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0031)http://www.hnjk.com.cn/map.html -->
<HTML><HEAD><TITLE></TITLE><LINK
href="main.css" type=text/css rel=stylesheet>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.3790.2817" name=GENERATOR></HEAD>
<BODY>
<SCRIPT language=JavaScript src="menu0.js">
</SCRIPT>
</BODY></HTML>main.css文件如下:
INPUT {
BORDER-TOP-WIDTH: 1px; PADDING-RIGHT: 1px; PADDING-LEFT: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 9pt; BORDER-LEFT-COLOR: #cccccc; BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: #cccccc; PADDING-BOTTOM: 1px; BORDER-TOP-COLOR: #cccccc; PADDING-TOP: 1px; FONT-FAMILY: ËÎÌå, Arial, Helvetica; HEIGHT: 18px; BACKGROUND-COLOR: #b0b2a2; BORDER-RIGHT-WIDTH: 1px; BORDER-RIGHT-COLOR: #cccccc
}
BODY {
SCROLLBAR-HIGHLIGHT-COLOR: buttonface; SCROLLBAR-SHADOW-COLOR: buttonface; SCROLLBAR-3DLIGHT-COLOR: buttonhighlight; SCROLLBAR-TRACK-COLOR: #eeeeee; SCROLLBAR-DARKSHADOW-COLOR: buttonshadow; font-color: #000066
}
.p10 {
FONT-SIZE: 10.5pt
}
.p9 {
FONT-SIZE: 9pt; PADDING-BOTTOM: 5px; LINE-HEIGHT: 150%; PADDING-TOP: 5px
}
.text {
FONT-SIZE: 9pt; FILTER: DropShadow(Color=#f5f5f5, OffX=1, OffY=1, Positive=1)
}
TD.menu {
BACKGROUND: #7d86aa
}
TD {
FONT-SIZE: 9pt; LINE-HEIGHT: 150%
}
.clsMenu {
BORDER-RIGHT: buttonhighlight 1px outset; BORDER-TOP: buttonhighlight 1px outset; VISIBILITY: hidden; BORDER-LEFT: buttonhighlight 1px outset; WIDTH: 100px; CURSOR: default; COLOR: #000000; BORDER-BOTTOM: buttonhighlight 1px outset; POSITION: absolute; BACKGROUND-COLOR: #f5f5f5
}
.menuitems {
PADDING-RIGHT: 10px; PADDING-LEFT: 20px; FONT-SIZE: 12px; COLOR: #333333; LINE-HEIGHT: 18px
}
.form1 {
FONT-SIZE: 9pt; BORDER-BOTTOM: #cccccc 1px solid
}
.form2 {
FONT-SIZE: 9pt; BORDER-BOTTOM: #999999 1px solid
}
.form3 {
BORDER-RIGHT: #999999 1px solid; FONT-SIZE: 9pt
}
.form4 {
BORDER-TOP: #cccccc 1px solid; FONT-SIZE: 9pt; BORDER-BOTTOM: #cccccc 1px solid
}
.form5 {
BORDER-TOP: #cccccc 1px solid; FONT-SIZE: 9pt
}
.form6 {
FONT-SIZE: 10.5pt; BORDER-BOTTOM: #999999 1px solid
}
.IN {
BORDER-TOP-WIDTH: 1px; PADDING-RIGHT: 1px; PADDING-LEFT: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 9pt; BORDER-LEFT-COLOR: #cccccc; BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: #cccccc; PADDING-BOTTOM: 1px; BORDER-TOP-COLOR: #cccccc; PADDING-TOP: 1px; FONT-FAMILY: ËÎÌå, Arial, Helvetica; HEIGHT: 18px; BACKGROUND-COLOR: #ffffff; BORDER-RIGHT-WIDTH: 1px; BORDER-RIGHT-COLOR: #cccccc
}
.form {
BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; FONT-SIZE: 9pt; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid; BACKGROUND-COLOR: white
}可是不知道为什么我一放到aspx页面中照上面的方式调用就不能正常显示了
郁闷啊不知道我讲清楚没
请高手们解答一下
帮帮偶..
在此感谢大家了
解决方案 »
- 难道vs08不允许?
- 大家进来讨论一下这个系统
- 问几个关于Javascript继承和命名空间的问题
- [求教]小问题,如何判断<%# Eval("xxx") %>的值
- 请问为什么Response.AddHeader方式的文件下载连接,如果点击“保存”可以直接下载,而点击“打开”则重复弹出界面再要求选择?
- 操作必须使用一个可更新的查询错误??
- DataGrid能否不显示表头?
- 关于asp.net+oracle11g性能问题,请大神给点意见,好意见会给高分的!!
- 急急急:如何向控件传递动态参数?
- 急急急,请问下,C#发邮件服务器端口需要怎么配置
- 关于大小包装单位的换算问题?
- 自家电脑作服务器的疑问!!
而且原来鼠标移到某菜单项上会高亮显示的,现在变成了整个菜单全部高亮,而且不停闪烁
不知道什么原因有没有人在asp.net程序的页面上做过自定义右键菜单啊?
谢谢各位的关注我把这些代码copy到在VS2005里建的相应的文件中然后就可以了
不能直接调用DW中建立的文件