V
varma.pothuri
Hi,
I want to create a contextMenu in the same page, which is having OWC
component. But when I right-click near to the OWC, the contextMenu goes
inside the OWC. Can any one please help me.
I copied the code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>ContextMenu </title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<style>
<!--
..skin0{
position:absolute;
width:140px;
border:1pt solid #808080;
background-color:#cccccc;
font-family:Verdana;
line-height:20px;
cursor:default;
font-size:14px;
z-index:100;
visibility:hidden;
}
..menuitems{
padding-left:10px;
padding-right:10px;
margin:2px;
font-family:Arial;
font-size:8pt;
border:1pt solid #cccccc;
}
..hritems{
padding: -10px;
margin : 0px;
}
-->
</style>
</head>
<body>
<div id="ie5menu" class="skin0" onMouseover="highlightie5(event)"
onMouseout="lowlightie5(event)" onClick="jumptoie5(event)"
display:none>
<div class="menuitems" url="http://dynamicdrive.com"
onclick="CopyToClipBoard();">Copy</div>
<div class="menuitems" url="http://dynamicdrive.com"
onclick="PasteFromClipBoard();">Paste</div>
</div>
<script language="JavaScript1.2">
function GetWindowSize()
{
this.myWidth = 0;
this.myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
this.myWidth = window.innerWidth;
this.myHeight = window.innerHeight;
}
else if( document.documentElement &&
(document.documentElement.clientWidth ||
document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
this.myWidth = document.documentElement.clientWidth;
this.myHeight = document.documentElement.clientHeight;
}
else if( document.body && ( document.body.clientWidth ||
document.body.clientHeight ) ) {
//IE 4 compatible
this.myWidth = document.body.clientWidth;
this.myHeight = document.body.clientHeight;
}
}
function test() {
alert('this is a test');
}
//set this variable to 1 if you wish the URLs of the highlighted menu
to be displayed in the status bar
var display_url=0
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all
if (ie5||ns6)
var menuobj=document.getElementById("ie5menu")
function showmenuie5(e){
//Find out how close the mouse is to the corner of the window
var rightedge=ie5? document.body.clientWidth-event.clientX :
window.innerWidth-e.clientX
var bottomedge=ie5? document.body.clientHeight-event.clientY :
window.innerHeight-e.clientY
//if the horizontal distance isn't enough to accomodate the width of
the context menu
if (rightedge<menuobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
menuobj.style.left=ie5?
document.body.scrollLeft+event.clientX-menuobj.offsetWidth :
window.pageXOffset+e.clientX-menuobj.offsetWidth
else
//position the horizontal position of the menu where the mouse was
clicked
menuobj.style.left=ie5? document.body.scrollLeft+event.clientX :
window.pageXOffset+e.clientX
//same concept with the vertical position
if (bottomedge<menuobj.offsetHeight)
menuobj.style.top=ie5? document.body.scrollTop+event.clientY :
window.pageYOffset+e.clientY;
else
menuobj.style.top=ie5? document.body.scrollTop+event.clientY :
window.pageYOffset+e.clientY;
menuobj.style.visibility="visible"
var posY = parseInt (menuobj.style.top) + menuobj.offsetHeight;
var wsize = new GetWindowSize();
window.status = posY + ' ' + wsize.myHeight + ' ' +
menuobj.offsetHeight;
if (posY > wsize.myHeight) {
posY = parseInt(wsize.myHeight) - menuobj.offsetHeight - 20;
window.status = posY ;
menuobj.style.top = posY;
}
return false
}
var trgObj = null;
var srcObj = null;
function getTarget(evt) {
if (!evt) { evt = window.event; }
if (document.all) { return (evt.srcElement); }
return (evt.target);
}
function CopyToClipBoard() {
clipboard = trgObj.value;
window.clipboardData.setData("Text", clipboard);
}
function PasteFromClipBoard() {
clipboard = window.clipboardData.getData("Text");
if (!clipboard || !trgObj.value) { return; }
trgObj.value = clipboard;
}
function hidemenuie5(e){
menuobj.style.visibility="hidden"
trgObj = getTarget (e);
if (trgObj.tagName != 'INPUT' && trgObj.type != 'text') { trgObj =
null; return; }
if (trgObj) { window.status = 'Target is ' + trgObj.tagName; }
}
function highlightie5(e){
var firingobj=ie5? event.srcElement : e.target
if
(firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){
if (ns6&&firingobj.parentNode.className=="menuitems")
firingobj=firingobj.parentNode //up one node
firingobj.style.backgroundColor="#CFD6E8"
firingobj.style.border="1pt solid #737B92"
firingobj.style.color="black"
if (display_url==1)
window.status=event.srcElement.url
}
}
function lowlightie5(e){
var firingobj=ie5? event.srcElement : e.target
if
(firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){
if (ns6&&firingobj.parentNode.className=="menuitems")
firingobj=firingobj.parentNode //up one node
firingobj.style.backgroundColor="#cccccc"
firingobj.style.border="1pt solid #cccccc"
firingobj.style.color="black"
window.status=''
}
}
function jumptoie5(e){
var firingobj=ie5? event.srcElement : e.target
if
(firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){
if (ns6&&firingobj.parentNode.className=="menuitems")
firingobj=firingobj.parentNode
if (firingobj.getAttribute("target"))
window.open(firingobj.getAttribute("url"),firingobj.getAttribute("target"))
}
}
if (ie5||ns6){
menuobj.style.display=''
document.oncontextmenu=showmenuie5
document.onclick=hidemenuie5
}
</script>
<br><br><br><br><br><br><br><br><br><br>
<center>
<object style="HEIGHT: 200; WIDTH: 200; z-index:-1" name="Excel"
classid="clsid:0002E559-0000-0000-C000-000000000046" id="Excel">
<param name="autoStart" value="-1"></object>
</center>
</body>
</html>
Thanks,
-Varma
I want to create a contextMenu in the same page, which is having OWC
component. But when I right-click near to the OWC, the contextMenu goes
inside the OWC. Can any one please help me.
I copied the code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>ContextMenu </title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<style>
<!--
..skin0{
position:absolute;
width:140px;
border:1pt solid #808080;
background-color:#cccccc;
font-family:Verdana;
line-height:20px;
cursor:default;
font-size:14px;
z-index:100;
visibility:hidden;
}
..menuitems{
padding-left:10px;
padding-right:10px;
margin:2px;
font-family:Arial;
font-size:8pt;
border:1pt solid #cccccc;
}
..hritems{
padding: -10px;
margin : 0px;
}
-->
</style>
</head>
<body>
<div id="ie5menu" class="skin0" onMouseover="highlightie5(event)"
onMouseout="lowlightie5(event)" onClick="jumptoie5(event)"
display:none>
<div class="menuitems" url="http://dynamicdrive.com"
onclick="CopyToClipBoard();">Copy</div>
<div class="menuitems" url="http://dynamicdrive.com"
onclick="PasteFromClipBoard();">Paste</div>
</div>
<script language="JavaScript1.2">
function GetWindowSize()
{
this.myWidth = 0;
this.myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
this.myWidth = window.innerWidth;
this.myHeight = window.innerHeight;
}
else if( document.documentElement &&
(document.documentElement.clientWidth ||
document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
this.myWidth = document.documentElement.clientWidth;
this.myHeight = document.documentElement.clientHeight;
}
else if( document.body && ( document.body.clientWidth ||
document.body.clientHeight ) ) {
//IE 4 compatible
this.myWidth = document.body.clientWidth;
this.myHeight = document.body.clientHeight;
}
}
function test() {
alert('this is a test');
}
//set this variable to 1 if you wish the URLs of the highlighted menu
to be displayed in the status bar
var display_url=0
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all
if (ie5||ns6)
var menuobj=document.getElementById("ie5menu")
function showmenuie5(e){
//Find out how close the mouse is to the corner of the window
var rightedge=ie5? document.body.clientWidth-event.clientX :
window.innerWidth-e.clientX
var bottomedge=ie5? document.body.clientHeight-event.clientY :
window.innerHeight-e.clientY
//if the horizontal distance isn't enough to accomodate the width of
the context menu
if (rightedge<menuobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
menuobj.style.left=ie5?
document.body.scrollLeft+event.clientX-menuobj.offsetWidth :
window.pageXOffset+e.clientX-menuobj.offsetWidth
else
//position the horizontal position of the menu where the mouse was
clicked
menuobj.style.left=ie5? document.body.scrollLeft+event.clientX :
window.pageXOffset+e.clientX
//same concept with the vertical position
if (bottomedge<menuobj.offsetHeight)
menuobj.style.top=ie5? document.body.scrollTop+event.clientY :
window.pageYOffset+e.clientY;
else
menuobj.style.top=ie5? document.body.scrollTop+event.clientY :
window.pageYOffset+e.clientY;
menuobj.style.visibility="visible"
var posY = parseInt (menuobj.style.top) + menuobj.offsetHeight;
var wsize = new GetWindowSize();
window.status = posY + ' ' + wsize.myHeight + ' ' +
menuobj.offsetHeight;
if (posY > wsize.myHeight) {
posY = parseInt(wsize.myHeight) - menuobj.offsetHeight - 20;
window.status = posY ;
menuobj.style.top = posY;
}
return false
}
var trgObj = null;
var srcObj = null;
function getTarget(evt) {
if (!evt) { evt = window.event; }
if (document.all) { return (evt.srcElement); }
return (evt.target);
}
function CopyToClipBoard() {
clipboard = trgObj.value;
window.clipboardData.setData("Text", clipboard);
}
function PasteFromClipBoard() {
clipboard = window.clipboardData.getData("Text");
if (!clipboard || !trgObj.value) { return; }
trgObj.value = clipboard;
}
function hidemenuie5(e){
menuobj.style.visibility="hidden"
trgObj = getTarget (e);
if (trgObj.tagName != 'INPUT' && trgObj.type != 'text') { trgObj =
null; return; }
if (trgObj) { window.status = 'Target is ' + trgObj.tagName; }
}
function highlightie5(e){
var firingobj=ie5? event.srcElement : e.target
if
(firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){
if (ns6&&firingobj.parentNode.className=="menuitems")
firingobj=firingobj.parentNode //up one node
firingobj.style.backgroundColor="#CFD6E8"
firingobj.style.border="1pt solid #737B92"
firingobj.style.color="black"
if (display_url==1)
window.status=event.srcElement.url
}
}
function lowlightie5(e){
var firingobj=ie5? event.srcElement : e.target
if
(firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){
if (ns6&&firingobj.parentNode.className=="menuitems")
firingobj=firingobj.parentNode //up one node
firingobj.style.backgroundColor="#cccccc"
firingobj.style.border="1pt solid #cccccc"
firingobj.style.color="black"
window.status=''
}
}
function jumptoie5(e){
var firingobj=ie5? event.srcElement : e.target
if
(firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){
if (ns6&&firingobj.parentNode.className=="menuitems")
firingobj=firingobj.parentNode
if (firingobj.getAttribute("target"))
window.open(firingobj.getAttribute("url"),firingobj.getAttribute("target"))
}
}
if (ie5||ns6){
menuobj.style.display=''
document.oncontextmenu=showmenuie5
document.onclick=hidemenuie5
}
</script>
<br><br><br><br><br><br><br><br><br><br>
<center>
<object style="HEIGHT: 200; WIDTH: 200; z-index:-1" name="Excel"
classid="clsid:0002E559-0000-0000-C000-000000000046" id="Excel">
<param name="autoStart" value="-1"></object>
</center>
</body>
</html>
Thanks,
-Varma