Click to See Complete Forum and Search --> : Right clicking on hyperlinks in Internet Explorer


mredding
09-22-2003, 08:46 PM
I am trying to develop a Windows training website at my office. I need to find a JavaScript that will allow a hyperlink to be opened by right-clicking on the link. It is important that no context menu appear when the link is right clicked. Can anyone help?

skriptor
09-23-2003, 12:34 AM
Hi, try something like this:

<html><head>
<script type="text/javascript" language="javascript">
document.oncontextmenu = goLink;
function goLink() {
if ( window.event.srcElement.tagName == "A" ) {
document.location.href = window.event.srcElement.href;
return false;
}
}
</script>
</head><body>
<a href="f1.htm">Link 1</a>
</body></html>

Good luck, skriptor

mredding
09-23-2003, 10:13 AM
Hi Scriptor,

Thanks a million for the script. It works nicely. I really appreciate it.

Mredding