I am having trouble figuring out how I can get a custom context menu to
appear at the point of the mouse click. When the user right clicks
inside a text box, I want my custom menu to appear at that point. The
below kind of works unless the page scrolls and is scrolled down the
page a ways. I need the menu to be placed correctly regardless of
scrollbar position.
function setMenu(elm){
document.getEle mentById('myMen u').style.visib ility='visible' ;
var x=document.body .scrollLeft + event.screenX;
var y=document.body .scrollTop + event.screenY;
document.getEle mentById('myMen u').style.left= x;
document.getEle mentById('myMen u').style.top=y ;
}
<input type="text" name="textfield " oncontextmenu=" setMenu(this);r eturn
false" />
<div id="myMenu" style="position :absolute;visib ility:hidden">
Some links here
</div>
Solutions or pointers for the major browsers appreciated.
John
appear at the point of the mouse click. When the user right clicks
inside a text box, I want my custom menu to appear at that point. The
below kind of works unless the page scrolls and is scrolled down the
page a ways. I need the menu to be placed correctly regardless of
scrollbar position.
function setMenu(elm){
document.getEle mentById('myMen u').style.visib ility='visible' ;
var x=document.body .scrollLeft + event.screenX;
var y=document.body .scrollTop + event.screenY;
document.getEle mentById('myMen u').style.left= x;
document.getEle mentById('myMen u').style.top=y ;
}
<input type="text" name="textfield " oncontextmenu=" setMenu(this);r eturn
false" />
<div id="myMenu" style="position :absolute;visib ility:hidden">
Some links here
</div>
Solutions or pointers for the major browsers appreciated.
John
Comment