支持IE和FireFox的右键菜单
来源:互联网 发布:重庆时时彩二星软件 编辑:程序博客网 时间:2024/05/19 22:06
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
- <!-- saved from url=(0053)http:
- <HTML><HEAD><TITLE></TITLE>
- <META http-equiv=Content-Type content="text/html; charset=gb2312">
- <STYLE>BODY {
- FONT-SIZE: 12px; MARGIN: 10px 0px 0px; FONT-FAMILY: "宋体"
- }
- .skin0 {
- BORDER-RIGHT: black 2px solid; BORDER-TOP: black 2px solid; VISIBILITY: hidden; BORDER-LEFT: black 2px solid; WIDTH: 100px; CURSOR: default; LINE-HEIGHT: 20px; PADDING-TOP: 4px; BORDER-BOTTOM: black 2px solid; FONT-FAMILY: "宋体"; POSITION: absolute; BACKGROUND-COLOR: menu; TEXT-ALIGN: left
- }
- .skin1 {
- BORDER-RIGHT: buttonhighlight 2px outset; BORDER-TOP: buttonhighlight 2px outset; FONT-SIZE: 10pt; VISIBILITY: hidden; BORDER-LEFT: buttonhighlight 2px outset; WIDTH: 100px; CURSOR: default; PADDING-TOP: 4px; BORDER-BOTTOM: buttonhighlight 2px outset; FONT-FAMILY: "宋体"; POSITION: absolute; BACKGROUND-COLOR: menu; TEXT-ALIGN: left
- }
- .menuitems {
- PADDING-RIGHT: 1px; PADDING-LEFT: 10px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px
- }
- </STYLE>
-
- <SCRIPT language=javascript>
- <!--
-
- var menuskin = "skin0";
-
- var display_url = false;
-
- function getEvent(){
- if(document.all) return window.event;
- func=getEvent.caller;
- while(func!=null){
- var arg0=func.arguments[0];
- if(arg0){
- if((arg0.constructor==Event || arg0.constructor ==MouseEvent)
- || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){
- return arg0;
- }
- }
- func=func.caller;
- }
- return null;
- }
-
- function showmenuie5() {
-
- var event=arguments[0] || window.event;
- 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 hidemenuie5() {
-
-
- ie5menu.style.visibility = "hidden";
- }
-
- function highlightie5(evt) {
-
-
-
-
- var event=evt || window.event;
- var element=event.srcElement || event.target;
- if (element.className == "menuitems") {
- element.style.backgroundColor = "highlight";
- element.style.color = "white";
-
-
-
- if (display_url)
- window.status = event.srcElement.url;
- }
- }
-
- function lowlightie5(evt) {
-
- var event=evt || window.event;
- var element=event.srcElement || event.target;
- if (element.className == "menuitems") {
- element.style.backgroundColor = "";
- element.style.color = "black";
-
- }
- }
-
-
- function jumptoie5(evt) {
-
- var event=evt || window.event;
- var element=event.srcElement || event.target;
-
- if (element.className == "menuitems") {
-
- if (element.getAttribute("target") != null)
- {
- window.open(element.getAttribute("url"), element.getAttribute("target"));
- }
- else
-
- window.location = element.getAttribute("url");
- }
- }
-
- </SCRIPT>
-
- <META content="MSHTML 6.00.2900.3059" name=GENERATOR></HEAD>
- <BODY>
- <CENTER>
- <P>点击右键看看效果-<A href="http://www.7dspace.com/" target=_blank>七度空间网页教学网</A>
- </P></CENTER>
- <br>
- <b id="test">点击右键看看效果</b>
- <br>
- <br>
- <br>
- <b id="test1">点击右键看看效果</b>
-
-
- <DIV class=skin0 id=ie5menu onmouseover=highlightie5(event) onclick=jumptoie5(event); onmouseout=lowlightie5(event)>
- <DIV class=menuitems url="javascript:history.back();">后退</DIV>
- <DIV class=menuitems url="javascript:history.forward();">前进</DIV>
- <HR>
- <DIV class=menuitems url="http://www.7dspace.com/doc/news/index.htm" target="_blank">业界新闻</DIV>
- <DIV class=menuitems url="http://www.7dspace.com/doc/guide/index.htm" target="_blank">建站指南</DIV>
- <DIV class=menuitems url="http://www.7dspace.com/doc/web/index.htm" target="_blank">网页制作</DIV>
- <DIV class=menuitems url="http://www.7dspace.com/doc/flash/index.htm" target="_blank">动画制作</DIV>
- <HR>
- <DIV class=menuitems url="http://www.7dspace.com/doc/effect/index.htm" target="_blank">网页特效</DIV>
- <DIV class=menuitems url="http://www.7dspace.com/doc/program/index.htm" target="_blank">网络编程</DIV>
- <HR>
- <DIV class=menuitems url="http://www.7dspace.com/help/about.htm" target="_blank">关于本站</DIV>
- <DIV class=menuitems url="http://www.7dspace.com/help/contact.htm">联系我们</DIV>
- </DIV>
-
- <SCRIPT language=JavaScript1.2>
-
-
-
-
- ie5menu.className = menuskin;
-
-
- document.getElementById("test").oncontextmenu = showmenuie5;
- document.getElementById("test1").oncontextmenu = showmenuie5;
-
-
- document.body.onclick = hidemenuie5;
-
- </SCRIPT>
- </BODY></HTML>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var isIe = (document.all)?true:false;
- var moveable=false;
- var topDivBorderColor = "#336699";
- var topDivBgColor = "#6795B4";
- var contentBgColor = "white";
- var contentFontColor = "black";
- var titleFontColor = "white";
- var index=1000000;
-
- function DivWindow(id,title,w,h,content)
- {
- this.id = id;
- this.zIndex = index +2;
- this.title = title;
- this.message = content;
- this.width = w;
- this.height = h;
- this.left = (document.body.clientWidth) ? (document.body.clientWidth - this.width)/2 : 0;
- this.top = (document.body.clientHeight) ? (document.body.clientHeight - this.height)/2 : 0;
-
-
- }
-
- DivWindow.prototype = {
-
- setPopupTopTitleFontColor:function(tFontColor)
- {
- titleFontColor = tFontColor;
- },
-
- setPopupTopBgColor:function(tBgColor)
- {
- topDivBgColor = tBgColor;
- },
-
- setPopupColor:function(borderColor,bgColor,tFontColor,cBgColor,fColor)
- {
- topDivBorderColor = borderColor;
- topDivBgColor = bgColor;
- titleFontColor = tFontColor;
- contentBgColor = cBgColor;
- contentFontColor = fColor;
- },
-
- open: function()
- {
- var sWidth,sHeight;
- sWidth=document.body.clientWidth;
- sHeight=document.body.clientHeight;
- var bgObj=document.createElement("div");
- bgObj.setAttribute('id','window'+this.id);
- var styles={"top":"0px","left":"0px","position":"absolute","background":"#245","width":sWidth+'px',"height":sHeight+"px"};
- if(isIe){
- styles.filter="alpha(opacity=0)";
- }
- else
- styles.opacity=0;
- test(bgObj,styles);
- document.body.appendChild(bgObj);
-
- showBackground(bgObj,25);
-
-
- var windowTopBgDiv = document.createElement("div");
- windowTopBgDiv.setAttribute('id','windowTopBg'+this.id);
- windowTopBgDiv.style.position = "absolute";
- windowTopBgDiv.style.zIndex = this.zIndex ;
- windowTopBgDiv.style.width = this.width ;
- windowTopBgDiv.style.height = this.height;
- windowTopBgDiv.style.left = this.left;
- windowTopBgDiv.style.top = this.top;
- windowTopBgDiv.style.background = topDivBgColor;
- windowTopBgDiv.style.fontSize = "9pt";
- windowTopBgDiv.style.cursor = "default";
- windowTopBgDiv.style.border = "1px solid " + topDivBorderColor;
- windowTopBgDiv.onmousedown=function(){
- if(windowTopBgDiv.style.zIndex!=index)
- {
- index = index + 2;
- var idx = index;
- windowTopBgDiv.style.zIndex=idx;
- }
- };
-
- var windowTopDiv = document.createElement("div");
- windowTopDiv.setAttribute('id','windowTop'+this.id);
- windowTopDiv.style.position = "absolute";
- windowTopDiv.style.background = topDivBgColor;
- windowTopDiv.style.color = titleFontColor;
- windowTopDiv.style.cursor = "move";
- windowTopDiv.style.height = 20;
- windowTopDiv.style.width = this.width;
-
- windowTopDiv.onmousedown=function(evt){
- var event=evt || window.event;
- if(event.button==1 || event.button==0)
- {
-
-
- if(windowTopDiv.setCapture)
- windowTopDiv.setCapture();
- else if(window.captureEvents)
- window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
-
- var win = windowTopDiv.parentNode;
-
- if(!event.clientX)event.clientX=event.pageX;
- if(!event.clientY)event.clientY=event.pageY;
- x0 = event.clientX;
- y0 = event.clientY;
-
-
- x1 = parseInt(win.style.left);
- y1 = parseInt(win.style.top);
-
-
-
-
- win.style.borderColor = topDivBorderColor;
- moveable = true;
- }
- };
-
-
- windowTopDiv.onmouseup=function(){
- if(moveable)
- {
- var win = windowTopDiv.parentNode;
- win.style.borderColor = topDivBgColor;
- windowTopDiv.style.backgroundColor = topDivBgColor;
- windowTopDiv.releaseCapture();
- if(windowTopDiv.releaseCapture)
- windowTopDiv.releaseCapture();
- else if(window.captureEvents)
- window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
- moveable = false;
- }
- };
-
- windowTopDiv.onmousemove=function(evt){
- if(moveable)
- {
- var event=evt || window.event;
- var arr = [0,400,0,300]
- if(!event.clientX)event.clientX=event.pageX;
- if(!event.clientY)event.clientY=event.pageY;
- var win = windowTopDiv.parentNode;
- var a=x1 + event.clientX - x0;
- var b=y1 + event.clientY - y0;
- win.style.left = a<arr[0]?arr[0]:a>arr[1]?arr[1]:a;
- win.style.top = b<arr[2]?arr[2]:b>arr[3]?arr[3]:b;
- }
- };
-
- windowTopDiv.ondblclick=function(){
- maxOrMinPopupDiv(windowTopOperateSpan,windowContentDiv);
- };
-
-
- var windowTopTitleSpan = document.createElement("span");
- windowTopTitleSpan.setAttribute('id','windowTopTitle'+this.id);
- windowTopTitleSpan.style.width = this.width-2*12-4;
- windowTopTitleSpan.style.paddingLeft = "3px";
- windowTopTitleSpan.innerHTML = this.title;
-
-
- var windowTopOperateSpan = document.createElement("span");
- windowTopOperateSpan.setAttribute('id','windowTopOperate'+this.id);
- windowTopOperateSpan.style.width = 12;
- windowTopOperateSpan.style.borderWidth = "0px";
- windowTopOperateSpan.style.color = titleFontColor;
- windowTopOperateSpan.style.fontFamily = "webdings";
- windowTopOperateSpan.style.cursor = "default";
- windowTopOperateSpan.innerHTML = "0";
-
- windowTopOperateSpan.onclick=function(){
- maxOrMinPopupDiv(windowTopOperateSpan,windowContentDiv);
- };
-
-
- var windowTopCloseSpan = document.createElement("span");
- windowTopCloseSpan.setAttribute('id','windowTopClose'+this.id);
- windowTopCloseSpan.style.width = 12;
- windowTopCloseSpan.style.borderWidth = "0px";
- windowTopCloseSpan.style.color = titleFontColor;
- windowTopCloseSpan.style.fontFamily = "webdings";
- windowTopCloseSpan.style.cursor = "default";
- windowTopCloseSpan.innerHTML = "r";
-
- windowTopCloseSpan.onclick=function(){
- windowTopDiv.removeChild(windowTopTitleSpan);
- windowTopDiv.removeChild(windowTopOperateSpan);
- windowTopDiv.removeChild(windowTopCloseSpan);
- windowTopBgDiv.removeChild(windowTopDiv);
- windowTopBgDiv.removeChild(windowContentDiv);
- document.body.removeChild(windowTopBgDiv);
- document.body.removeChild(bgObj);
- };
-
-
- var windowContentDiv = document.createElement("div");
- windowContentDiv.setAttribute('id','windowContent'+this.id);
- windowContentDiv.style.background = contentBgColor;
- windowContentDiv.style.color = contentFontColor;
- windowContentDiv.style.cursor = "default";
- windowContentDiv.style.height = (this.height - 20 -6);
- windowContentDiv.style.width = this.width;
- windowContentDiv.style.position = "relative";
- windowContentDiv.style.left = 0;
- windowContentDiv.style.top = 24;
-
- windowContentDiv.style.lineHeight = "20px";
- windowContentDiv.style.fontSize = "10pt";
- windowContentDiv.style.wordBreak = "break-all";
- windowContentDiv.style.padding = "3px";
- windowContentDiv.innerHTML = this.message;
-
-
- windowTopDiv.appendChild(windowTopTitleSpan);
- windowTopDiv.appendChild(windowTopOperateSpan);
- windowTopDiv.appendChild(windowTopCloseSpan);
- windowTopBgDiv.appendChild(windowTopDiv);
- windowTopBgDiv.appendChild(windowContentDiv);
- document.body.appendChild(windowTopBgDiv);
- }
- }
-
-
- function maxOrMinPopupDiv(windowTopOperateSpan,windowContentDiv)
- {
- var win = windowTopOperateSpan.parentNode.parentNode;
- var tit = windowTopOperateSpan.parentNode;
- var flg = windowContentDiv.style.display=="none";
- if(flg)
- {
- win.style.height = parseInt(windowContentDiv.style.height) + parseInt(tit.style.height) + 2*2;
- windowContentDiv.style.display = "block";
- windowTopOperateSpan.innerHTML = "0";
- }
- else
- {
- win.style.height = parseInt(tit.style.height) + 2*2;
- windowTopOperateSpan.innerHTML = "2";
- windowContentDiv.style.display = "none";
- }
- }
-
- function showBackground(obj,endInt)
- {
- if(isIe)
- {
- obj.filters.alpha.opacity+=1;
- if(obj.filters.alpha.opacity<endInt)
- {
- setTimeout(function(){this.showBackground(obj,endInt)},5);
- }
- }
- else
- {
- var al=parseFloat(obj.style.opacity);al+=0.01;
- obj.style.opacity=al;
- if(al<(endInt/100))
- {
- setTimeout(function(){this.showBackground(obj,endInt)},5);
- }
- }
- }
-
- function closeDivWindow(id)
- {
- var windowTopTitleSpan = document.getElementById("windowTopTitle"+id);
- var windowTopOperateSpan = document.getElementById("windowTopOperate"+id);
- var windowTopCloseSpan = document.getElementById("windowTopClose"+id);
- var windowTopDiv = document.getElementById("windowTop"+id);
- var windowTopBgDiv = document.getElementById("windowTopBg"+id);
- var windowContentDiv = document.getElementById("windowContent"+id);
- var bgObj = document.getElementById("window"+id);
-
- windowTopDiv.removeChild(windowTopTitleSpan);
- windowTopDiv.removeChild(windowTopOperateSpan);
- windowTopDiv.removeChild(windowTopCloseSpan);
- windowTopBgDiv.removeChild(windowTopDiv);
- windowTopBgDiv.removeChild(windowContentDiv);
- document.body.removeChild(windowTopBgDiv);
- document.body.removeChild(bgObj);
- }
-
- function test(dom,styles){
- for(key in styles){
- dom.style[key]=styles[key];
- }
- }