Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Right-Click Option Code(JavaScript)

Status
Not open for further replies.

powderkeg1

Technical User
Apr 14, 2001
58
JP
Hello All,

I believe there exists such a code that allows you to manipulate what options your viewers have in the menu when they right click a page, is this true and does someone here know it..? Cheers all.

Powderkeg1
 
Try this:

<HEAD>

<style>
<!--
.skin {
cursor:default;
font:menutext;
position:absolute;
text-align:left;
font-family: Arial, Helvetica, sans-serif;
font-size: 10pt;
width:120px;
background-color:menu;
border:1 solid buttonface;
visibility:hidden;
border:2 outset buttonhighlight;
}
.menuitems {
padding-left:15px;
padding-right:10px;
}
-->
</style>

<SCRIPT LANGUAGE=&quot;JavaScript1.2&quot;>

var menuskin = &quot;skin&quot;;
var display_url = 0;
function showmenuie5() {
var rightedge = document.body.clientWidth-event.clientX;
var bottomedge = document.body.clientHeight-event.clientY;
if (rightedge < ie5menu.offsetWidth)
ie5menu.style.left = document.body.scrollLeft + event.clientX - ie5menu.offsetWidth;
else
ie5menu.style.left = document.body.scrollLeft + event.clientX;
if (bottomedge < ie5menu.offsetHeight)
ie5menu.style.top = document.body.scrollTop + event.clientY - ie5menu.offsetHeight;
else
ie5menu.style.top = document.body.scrollTop + event.clientY;
ie5menu.style.visibility = &quot;visible&quot;;
return false;
}
function hidemenuie5() {
ie5menu.style.visibility = &quot;hidden&quot;;
}
function highlightie5() {
if (event.srcElement.className == &quot;menuitems&quot;) {
event.srcElement.style.backgroundColor = &quot;highlight&quot;;
event.srcElement.style.color = &quot;white&quot;;
if (display_url)
window.status = event.srcElement.url;
}
}
function lowlightie5() {
if (event.srcElement.className == &quot;menuitems&quot;) {
event.srcElement.style.backgroundColor = &quot;&quot;;
event.srcElement.style.color = &quot;black&quot;;
window.status = &quot;&quot;;
}
}
function jumptoie5() {
if (event.srcElement.className == &quot;menuitems&quot;) {
if (event.srcElement.getAttribute(&quot;target&quot;) != null)
window.open(event.srcElement.url, event.srcElement.getAttribute(&quot;target&quot;));
else
window.location = event.srcElement.url;
}
}
// End -->
</script>
</HEAD>

<BODY>

<div id=&quot;ie5menu&quot; class=&quot;skin0&quot; onMouseover=&quot;highlightie5()&quot; onMouseout=&quot;lowlightie5()&quot; onClick=&quot;jumptoie5();&quot;>
<div class=&quot;menuitems&quot; url=&quot;javascript:history.back();&quot;>Go Back</div>
<div class=&quot;menuitems&quot; url=&quot; Home</div>
<hr>
<div class=&quot;menuitems&quot; url=&quot;<div class=&quot;menuitems&quot; url=&quot; Forum</div>
<hr>
<div class=&quot;menuitems&quot; url=&quot;<div class=&quot;menuitems&quot; url=&quot;</div>
<script language=&quot;JavaScript1.2&quot;>
if (document.all && window.print) {
ie5menu.className = menuskin;
document.oncontextmenu = showmenuie5;
document.body.onclick = hidemenuie5;
}
</script>

This only works in IE, and not in NS ok?? try looking at sites like: and for more scripts, ok?? I have not failed; I merely found 100,000 different ways of not succeding...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top