Rod
16.05.2001, 06:18
Hi guys! How do you capture right click in IE4 IE5 IE6 NS4 NS6?
I'm creating a menu thats activated by right-click. Please help.
Here is the code:
<html>
<head>
<title>Cross-browser Dynamic HTML Scripts - ContextMenu</title>
<style type="text/css">
body {background:#FFFFFF; color:#000000; font-family:verdana,arial;}
div {font-family:verdana,arial;}
.justify {text-align:justify;}
font {font-family:verdana,arial; color:#000000;}
.text {font-size:11px;}
.link {font-size:11px;}
.h0 {font-weight:bold; font-size:13px;}
.h1 {font-weight:bold; font-size:15px;}
.h2 {font-weight:bold; font-size:18px;}
.h3 {font-weight:bold; font-size:20px;}
#divMenu {position:absolute; z-index:10000; visibility:hidden; width:100px; background-color:#DDDDDD; layer-background-color:#DDDDDD;}
.clMenu {font-family:verdana,arial; font-size:10px; color:#333366; border-width:1px; border-style:solid; border-color:#CCCCCC; padding:4px;}
.clMenuns4 {width:100px; font-family:verdana,arial; font-size:11px; color:#333366; border-width:1px; border-style:solid; border-color:#CCCCCC;}
.menuLinks {text-decoration:none; font-family:verdana,arial; font-size:11px; color:#333366;}
</style>
<script type="text/javascript" language="javascript">
/************************************************** ******************************
Copyright (C) 2001 Rod Morelos
This script is made by and copyrighted to Rod Morelos
wankoi@usa.net || wankoi@hotmail.com
************************************************** ******************************/
// Default browsercheck, added to all scripts!
function checkBrowser()
{
this.ver=navigator.appVersion;
this.dom=document.getElementById?1:0;
this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
this.ie4=(document.all && !this.dom)?1:0;
this.ns6=(this.dom && parseInt(this.ver) >= 5)?1:0;
this.ns4=(document.layers && !this.dom)?1:0;
this.w3c=(this.ie5 || this.ie6 || this.ns6);
this.ie=(this.ie4 || this.ie5 || this.ie6);
this.ns=(this.ns4 || this.ns6);
this.bw=(this.ie4 || this.ie5 || this.ie6 || this.ns4 || this.ns6);
return this
}
var bw=new checkBrowser();
// Makes crossbrowser object
function makeObject(obj)
{
this.css=bw.w3c?document.getElementById(obj).style :bw.ie4?document.all[obj].style:bw.ns4?document.layers[obj]:0;
this.doc=bw.w3c?document.getElementById(obj):bw.ie 4?document.all[obj]:bw.ns4?document.layers[obj]:0;
this.wri=bw.w3c?document.getElementById(obj):bw.ie 4?document.all[obj]:bw.ns4?document.layers[obj].document:0;
this.writeIt=b_writeIt;
this.showIt=b_showIt;
this.hideIt=b_hideIt;
this.moveIt=b_moveIt;
this.oWidth=b_oWidth;
this.oHeight=b_oHeight;
return this
}
// Write the text to the object
function b_writeIt(text)
{
if (bw.ns4)
{
this.wri.open();
this.wri.write(text);
this.wri.close();
}
else if (bw.ie4 || bw.w3c) this.wri.innerHTML=text;
}
// Makes an object's visibiltiy visible
function b_showIt()
{
this.css.visibility='visible';
}
// Makes an object's visibiltiy hidden
function b_hideIt()
{
this.css.visibility='hidden';
}
// Moves the object
function b_moveIt(xL,yT)
{
this.xL=xL;
this.yT=yT;
this.css.left=this.xL;
this.css.top=this.yT;
}
// Get object width
function b_oWidth()
{
if (bw.ns4) if (this.doc.width) return this.doc.width; else return this.doc.clip.width;
if (bw.ie) if (this.css.pixelWidth) return this.css.pixelWidth; else return this.doc.offsetWidth;
if (bw.ns6) if (this.css.width) return parseInt(this.css.width); else return parseInt(this.doc.offsetWidth);
}
// Get object height
function b_oHeight()
{
if (bw.ns4) if (this.doc.height) return this.doc.height; else return this.doc.clip.height;
if (bw.ie) if (this.css.pixelHeight) return this.css.pixelHeight; else return this.doc.offsetHeight;
if (bw.ns6) if (this.css.height) return parseInt(this.css.height); else return parseInt(this.doc.offsetHeight);
}
function showmenu(e)
{
pagewidth = bw.ns?window.innerWidth:document.body.clientWidth;
pageheight = bw.ns?window.innerHeight:document.body.clientHeigh t;
pagescrollx = bw.ns?window.pageXOffset:document.body.scrollLeft;
pagescrolly = bw.ns?window.pageYOffset:document.body.scrollTop;
cursorx = bw.ns?e.pageX:window.event.x;
cursory = bw.ns?e.pageY:window.event.y;
if (cursorx+oMenu.oWidth()>pagewidth) xLeft=cursorx-oMenu.oWidth()+pagescrollx;
else xLeft=cursorx+pagescrollx;
if (cursory+oMenu.oHeight()>pageheight) yTop=cursory-oMenu.oHeight()+pagescrolly;
else yTop=cursory+pagescrolly;
oMenu.moveIt(xLeft,yTop);
oMenu.showIt();
return false
}
function hidemenu()
{
oMenu.hideIt();
}
function init()
{
oMenu = new makeObject('divMenu');
menuLinks = 'Test Link 1 (javascript:;)
Test Link 2 (javascript:;)
Test Link 3 (javascript:;)
Test Link 4 (javascript:;)
Test Link 5 (javascript:;)';
if (!bw.ns4) oMenu.writeIt('<div class="clMenu">'+menuLinks+'</div>');
else oMenu.writeIt('<div class="clMenuns4">'+menuLinks+'</div>');
document.onclick=showmenu
}
onload=init;
</script>
</head>
<body>
<font class="h1">Cross-browser Dynamic HTML Scripts - ContextMenu</font>
<div id="divMenu"></div>
</body>
</html>
Thanks in advance. =)
Rad
[url="http://www.e-syed.net/viewsrc"]viewsrc[/url:l06vqq5io8]
I'm creating a menu thats activated by right-click. Please help.
Here is the code:
<html>
<head>
<title>Cross-browser Dynamic HTML Scripts - ContextMenu</title>
<style type="text/css">
body {background:#FFFFFF; color:#000000; font-family:verdana,arial;}
div {font-family:verdana,arial;}
.justify {text-align:justify;}
font {font-family:verdana,arial; color:#000000;}
.text {font-size:11px;}
.link {font-size:11px;}
.h0 {font-weight:bold; font-size:13px;}
.h1 {font-weight:bold; font-size:15px;}
.h2 {font-weight:bold; font-size:18px;}
.h3 {font-weight:bold; font-size:20px;}
#divMenu {position:absolute; z-index:10000; visibility:hidden; width:100px; background-color:#DDDDDD; layer-background-color:#DDDDDD;}
.clMenu {font-family:verdana,arial; font-size:10px; color:#333366; border-width:1px; border-style:solid; border-color:#CCCCCC; padding:4px;}
.clMenuns4 {width:100px; font-family:verdana,arial; font-size:11px; color:#333366; border-width:1px; border-style:solid; border-color:#CCCCCC;}
.menuLinks {text-decoration:none; font-family:verdana,arial; font-size:11px; color:#333366;}
</style>
<script type="text/javascript" language="javascript">
/************************************************** ******************************
Copyright (C) 2001 Rod Morelos
This script is made by and copyrighted to Rod Morelos
wankoi@usa.net || wankoi@hotmail.com
************************************************** ******************************/
// Default browsercheck, added to all scripts!
function checkBrowser()
{
this.ver=navigator.appVersion;
this.dom=document.getElementById?1:0;
this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
this.ie4=(document.all && !this.dom)?1:0;
this.ns6=(this.dom && parseInt(this.ver) >= 5)?1:0;
this.ns4=(document.layers && !this.dom)?1:0;
this.w3c=(this.ie5 || this.ie6 || this.ns6);
this.ie=(this.ie4 || this.ie5 || this.ie6);
this.ns=(this.ns4 || this.ns6);
this.bw=(this.ie4 || this.ie5 || this.ie6 || this.ns4 || this.ns6);
return this
}
var bw=new checkBrowser();
// Makes crossbrowser object
function makeObject(obj)
{
this.css=bw.w3c?document.getElementById(obj).style :bw.ie4?document.all[obj].style:bw.ns4?document.layers[obj]:0;
this.doc=bw.w3c?document.getElementById(obj):bw.ie 4?document.all[obj]:bw.ns4?document.layers[obj]:0;
this.wri=bw.w3c?document.getElementById(obj):bw.ie 4?document.all[obj]:bw.ns4?document.layers[obj].document:0;
this.writeIt=b_writeIt;
this.showIt=b_showIt;
this.hideIt=b_hideIt;
this.moveIt=b_moveIt;
this.oWidth=b_oWidth;
this.oHeight=b_oHeight;
return this
}
// Write the text to the object
function b_writeIt(text)
{
if (bw.ns4)
{
this.wri.open();
this.wri.write(text);
this.wri.close();
}
else if (bw.ie4 || bw.w3c) this.wri.innerHTML=text;
}
// Makes an object's visibiltiy visible
function b_showIt()
{
this.css.visibility='visible';
}
// Makes an object's visibiltiy hidden
function b_hideIt()
{
this.css.visibility='hidden';
}
// Moves the object
function b_moveIt(xL,yT)
{
this.xL=xL;
this.yT=yT;
this.css.left=this.xL;
this.css.top=this.yT;
}
// Get object width
function b_oWidth()
{
if (bw.ns4) if (this.doc.width) return this.doc.width; else return this.doc.clip.width;
if (bw.ie) if (this.css.pixelWidth) return this.css.pixelWidth; else return this.doc.offsetWidth;
if (bw.ns6) if (this.css.width) return parseInt(this.css.width); else return parseInt(this.doc.offsetWidth);
}
// Get object height
function b_oHeight()
{
if (bw.ns4) if (this.doc.height) return this.doc.height; else return this.doc.clip.height;
if (bw.ie) if (this.css.pixelHeight) return this.css.pixelHeight; else return this.doc.offsetHeight;
if (bw.ns6) if (this.css.height) return parseInt(this.css.height); else return parseInt(this.doc.offsetHeight);
}
function showmenu(e)
{
pagewidth = bw.ns?window.innerWidth:document.body.clientWidth;
pageheight = bw.ns?window.innerHeight:document.body.clientHeigh t;
pagescrollx = bw.ns?window.pageXOffset:document.body.scrollLeft;
pagescrolly = bw.ns?window.pageYOffset:document.body.scrollTop;
cursorx = bw.ns?e.pageX:window.event.x;
cursory = bw.ns?e.pageY:window.event.y;
if (cursorx+oMenu.oWidth()>pagewidth) xLeft=cursorx-oMenu.oWidth()+pagescrollx;
else xLeft=cursorx+pagescrollx;
if (cursory+oMenu.oHeight()>pageheight) yTop=cursory-oMenu.oHeight()+pagescrolly;
else yTop=cursory+pagescrolly;
oMenu.moveIt(xLeft,yTop);
oMenu.showIt();
return false
}
function hidemenu()
{
oMenu.hideIt();
}
function init()
{
oMenu = new makeObject('divMenu');
menuLinks = 'Test Link 1 (javascript:;)
Test Link 2 (javascript:;)
Test Link 3 (javascript:;)
Test Link 4 (javascript:;)
Test Link 5 (javascript:;)';
if (!bw.ns4) oMenu.writeIt('<div class="clMenu">'+menuLinks+'</div>');
else oMenu.writeIt('<div class="clMenuns4">'+menuLinks+'</div>');
document.onclick=showmenu
}
onload=init;
</script>
</head>
<body>
<font class="h1">Cross-browser Dynamic HTML Scripts - ContextMenu</font>
<div id="divMenu"></div>
</body>
</html>
Thanks in advance. =)
Rad
[url="http://www.e-syed.net/viewsrc"]viewsrc[/url:l06vqq5io8]