?
Solved

How can I let the href have no popmenu?

Posted on 2003-02-24
4
Medium Priority
?
186 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

762 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