?
Solved

How can I let the href have no popmenu?

Posted on 2003-02-24
4
Medium Priority
?
195 Views
Last Modified: 2010-04-09
In one page, I want let the hyperlink have no the popmenu,  when I right click it? and how can I change the popmenu dynamic?

wait for your answer!thanks!
0
Comment
Question by:lakeryu
  • 2
  • 2
4 Comments
 
LVL 3

Expert Comment

by:hexagon47
ID: 8008433
function avoidRightClick()
{
     if (event.button==2||event.button==3)
     {
     alert('no right button allowed');
     return false;
     }
}
document.onmousedown=avoidRightClick;

this should do it for what concerns the menu not to appear when you right click (obviously customise it where I have put the alert()).
Re the second questions, you mean that in certain pages you want a custom menu to appear instead of the normal one when you right click on a link?
0
 

Author Comment

by:lakeryu
ID: 8013244
Thank you for your answer! Your method is right, But I don't want popup anythig include the warning message box.

the second questions, what you say is right. I want a custom menu to appear instead of the normal one when I right click on a link!

thanks!
0
 
LVL 3

Accepted Solution

by:
hexagon47 earned 150 total points
ID: 8015554
<html>
<head>
<script language="javascript">
initBrowser();
function initBrowser()
{
dom = (document.getElementById)? true:false;
ie4 = (document.all && !dom)? true:false;
ie5 = (dom && (navigator.appVersion.indexOf("MSIE 5")>-1 || navigator.appVersion.indexOf("MSIE 6")>-1))? true:false;
ns4 = (document.layers)? true:false;
ns6 = (document.createRange)? true:false;
opera = (navigator.userAgent.indexOf("Opera")>-1)? true:false;
}
function initMouseEvents()
{
document.onmousemove = mouseMove;
if (ns4) document.captureEvents(Event.MOUSEMOVE);
}
function mouseMove(e)
{
document.mouseX = (ns4||ns6)? e.pageX : event.x+document.body.scrollLeft;
document.mouseY = (ns4||ns6)? e.pageY : event.y+document.body.scrollTop;
status=document.mouseX+","+document.mouseY;
return true;
}
function divShow()
{
document.getElementById('menuDiv').style.display = 'block';
document.getElementById('menuDiv').style.left = document.mouseX -10;
document.getElementById('menuDiv').style.top = document.mouseY -10;
}

function divHide()
{
document.getElementById('menuDiv').style.display = 'none';
}

function rightClickMenu(e)
{
if (event.button==2||event.button==3)
{
divShow();
return true;
}
}
document.onmousedown=rightClickMenu
</script>
</head>
<body onload="initMouseEvents();" oncontextmenu="return false" onclick="divHide()">
<a href="dumb.html">link1</a><br />
<a href="dumb.html">link2</a><br />
<a href="dumb.html">link3</a><br />
<a href="dumb.html">link4</a><br />
<div style="border:1px solid #000000; background-color:#999999; display:none; position:absolute; z-index:10;left:0; top:0; padding:15px;" id="menuDiv"><a href="dumb.html">my link</a><br /><a href="dumb.html">my link</a><br /><a href="dumb.html">my link</a><br /><a href="dumb.html">my link</a><br /></div>

Click outside of the div to make it disappear.<br />
If you want no menu to appear just comment out this line
document.onmousedown=rightClickMenu<br />
Hope this was of help

</body>
</html>
0
 

Author Comment

by:lakeryu
ID: 8039813
Thanks very much!
now it worked correctly!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

616 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question