Home > Web Front-end > JS Tutorial > Dron right-click menu v1.0_javascript skills

Dron right-click menu v1.0_javascript skills

PHP中文网
Release: 2016-05-16 19:24:40
Original
953 people have browsed it

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<HTML> 
<HEAD> 
<TITLE> New Document </TITLE> 
<META NAME="Generator" CONTENT="EditPlus"> 
<META NAME="Author" CONTENT=""> 
<META NAME="Keywords" CONTENT=""> 
<META NAME="Description" CONTENT=""> 
<link rel="stylesheet" href="rm.css" type="text/css" media="all"> 
</HEAD> 

<BODY onclick="bodyclick(event)" oncontextmenu="return showcontextmenu(event)"> 
<script type="text/javascript"> 
/*******************************************\ 
  Dron右键菜单 v1.0 
  This JavaScript was writen by Dron. 
  @2003-2008 Ucren.com All rights reserved. 
  (转载或应用请保留此版权信息) 
\*******************************************/ 
var ie = (navigator.appVersion.indexOf("MSIE")!=-1);//IE 
var ff = (navigator.userAgent.indexOf("Firefox")!=-1);//Firefox 
document.write("<div id=\"rightmenu\"></div>"); 
document.write("<div id=\"rightmenubg\"></div>"); 
Array.prototype.c = Array.prototype.concat; 
function buffer() 
{ 
    var s = []; 
    s = s.c(["<a href=\"\"> 项目一</a>"]); 
    s = s.c(["<a href=\"\"> 项目二</a>"]); 
    s = s.c(["<a href=\"\"> 项目三</a>"]); 
    s = s.c(["<a href=\"\"> 项目四</a>"]); 
    s = s.c(["<a href=\"\"> 项目五</a>"]); 
    s = s.c(["<a href=\"\"> 项目六</a>"]); 
    s = s.c(["<a href=\"\"> 项目七</a>"]); 
    s = s.c(["<a href=\"\"> 项目作</a>"]); 
    s = s.join(""); 
    document.getElementById("rightmenu").innerHTML = s; 
} 
var rightmenu = document.getElementById("rightmenu"); 
var rightmenubg = document.getElementById("rightmenubg"); 
var body = document.body; 
var ex=0,ey=0; 
function showcontextmenu(evt) 
{ 
    ex = evt.clientX;ey = evt.clientY; 
    rxy(); 
    rightmenu.style.display = "block"; 
    rightmenubg.style.display = "block"; 
    evt.cancelBubble = true; 
    return false; 
} 
function bodyclick(evt) 
{ 
    rightmenu.style.display = "none";//关闭右键菜单 
    rightmenubg.style.display = "none";//关闭右键菜单 
} 
function rxy() 
{ 
    var step=3; 
    if(ie){step=1} 
    if(ff){step=6} 
    if(ex+150>body.clientWidth) 
    { 
        rightmenu.style.left = ex - 150; 
        rightmenubg.style.left = ex - 150 + step; 
    } 
    else 
    { 
        rightmenu.style.left = ex; 
        rightmenubg.style.left = ex + step; 
    } 
    if(ey+200>body.clientHeight) 
    { 
        rightmenu.style.top = ey - 160; 
        rightmenubg.style.top = ey - 160 + step; 
    } 
    else 
    { 
        rightmenu.style.top = ey; 
        rightmenubg.style.top = ey + step; 
    } 
} 
function showcontextmenu(evt) 
{ 
    ex = evt.clientX;ey = evt.clientY; 
    rxy(); 
    rightmenu.style.display = "block"; 
    rightmenubg.style.display = "block"; 
    evt.cancelBubble = true; 
    return false; 
} 
window.onload = function() 
{ 
    buffer(); 
} 
</script> 
</BODY> 
</HTML>
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template