Right mouse-click somewhere in this page...
Copy and paste the following style declaration in the HEAD section of your page:
Select all...
<style type="text/css"> .link{ cursor:default; text-decoration:none; color:black; font-size:10pt; font-family:sans-serif; padding:5; } .normtext{ color:black; font-size:10pt; font-family:sans-serif; font-weight:bold; padding:3; } #conmenu { cursor:default; position:absolute; top:0px; left:0px; visibility:hidden; background-color:lightgrey; layer-background-color:lightgrey; border:outset 2px; font-size:10pt; font-family:sans-serif; font-weight:normal; color:#00436e; width:160px; padding:1 2 0 2; } #conshadow{ position:absolute; top:0px; left:0px; visibility:hidden; background-color:black; layer-background-color:black; } </style>
Copy and paste the following script in the BODY section of your page:
Select all...
<script language="javascript"> //***************************************************** // TITLE: CONTEXT MENU V1.1 // AUTHOR: Brian Gosselin // SITE: HTTP://SCRIPTASYLUM.COM // EMAIL: SCRIPTASYLUM@HOTMAIL.COM // SUPPORT: WORKS IN NETSCAPE 4+ AND 6+. WORKS IN IE4+ // KNOWN BUGS: BOX DOES NOT APPEAR CORRECTLY WHEN OVER FORM // ELEMENTS IN NETSCAPE4.X. AS A RESULT, I HAVE // CREATED PROVISIONS FOR THIS. SEE BELOW. //***************************************************** var menuNormColor="lightgrey"; //NORMAL COLOR OF THE MENU ITEMS var menuHoverColor="#0084d8"; //COLOR OF THE MENU ITEMS ONMOUSEOVER // THE ARRAY BELOW CONTAINS THE MENU ITEMS // FORMAT: // [ 'LINK TEXT TO APPEAR IN MENU' , 'LINK HREF' , 'TARGET WINDOW/FRAME' ]; // JUST ADD ARRAY ITEMS AS NEEDED KEEPING NUMBER SEQUENCE // TO ADD REGULAR HTML/TEXT, USE THE FOLLOWING FORMAT: // [ 'REGULAR TEXT/HTML HERE' ]; var menu=Array(); menu[0]=['
- JavaScript -
']; menu[1]=['JavaScript Alert Box', 'javascript:alert(\'This is a JavaScript alert box...\')', '']; menu[2]=['Email me...', 'mailto:scriptasylum@hotmail.com', '']; menu[3]=['Print...', 'javascript:window.print();', '']; menu[4]=['Refresh this page.','javascript:history.go(0)', '']; menu[5]=['
- Links -
']; menu[6]=['Script Asylum', 'http://scriptasylum.com', '_blank']; menu[7]=['Dynamic Drive', 'http://dynamicdrive.com', '_blank']; menu[8]=['Javascript Source', 'http://javascriptsource.com', '_blank']; menu[9]=['Right-click the mouse again to dismiss...']; var disableNS4=false; // BECAUSE THE MENU DOESNT LOOK RIGHT WHEN THE PAGE CONTAINS // FORMS IN NS4, SET THIS VALUE TO true TO USE THE DEFAULT // CONTEXT MENU. THIS EFFECTS NS4.X BROWSERS ONLY. //****************** NO NEED TO EDIT BEYOND HERE ******************** //*** IF YOU HAVE OTHER SCRIPTS THAT TRAP THE WINDOW.ONLOAD EVENT *** //******** OR THE WINDOW.ONRESIZE EVENT, YOU CAN ADD THEM TO ******** //******* THIS SCRIPT ! JUST SCROLL DOWN AND PUT THEM IN THE ******** //******************** APPROPRIATE PLACE(S). ************************ ns4 = (navigator.appName.indexOf("Netscape")>=0 && document.layers)? true : false; ie4 = (document.all && !document.getElementById)? true : false; ie5 = (document.all && document.getElementById)? true : false; ns6 = (document.getElementById && navigator.appName.indexOf("Netscape")>=0 )? true: false; w3c = (document.getElementById)? true : false; var mx=0; var my=0; var conmenu; var conshadow; var windowloaded=false; var opened=false; function setc(ref,c){ if(ns4)ref.bgColor=c; else ref.style.backgroundColor=c; } var txt='
'; txt+='
'; for(i=0;i
'+menu[i][0]+'
'; }else{ txt+=(ns4)?'
':'
'; txt+='
'+menu[i][0]+'
'; txt+=(ns4)?'':'
'; }} txt+='
'; document.write(txt); function ns4trap(evt){ if(evt.which==2||evt.which==3){ showmenu(); return false; }} function showmenu(){ if(windowloaded){ if(opened){ if(ns4){ conmenu.visibility="hide"; conshadow.visibility="hide"; conmenu.moveTo(0,0); conshadow.moveTo(0,0); }else{ conmenu.style.visibility="hidden"; conshadow.style.visibility="hidden"; conmenu.style.left='0px'; conmenu.style.top='0px'; conshadow.style.left='0px'; conshadow.style.top='0px'; } opened=false; }else{ opened=true; var wh=(ie4||ie5)?document.body.clientHeight:window.innerHeight; var sx=(ie4||ie5)?document.body.scrollLeft:pageXOffset; var sy=(ie4||ie5)?document.body.scrollTop:pageYOffset; if(ns4){ conmenu.moveTo(mx,my); conshadow.moveTo(mx+8,my+8); conmenu.visibility="show"; conshadow.visibility="show"; }else{ conmenu.style.left=mx+((ie4||ie5)?sx:0)+'px'; conmenu.style.top=my+((ie4||ie5)?sy:0)+'px'; conshadow.style.left=mx+10+((ie4||ie5)?sx:0)+'px'; conshadow.style.top=my+10+((ie4||ie5)?sy:0)+'px'; setTimeout('conmenu.style.visibility="visible"; conshadow.style.visibility="visible"; ',50); }}}} if(ns4&&!disableNS4){ document.captureEvents(Event.MOUSEDOWN|Event.MOUSEMOVE); document.onmousedown=ns4trap; }else{ document.oncontextmenu=function(){ showmenu(); return false; }} document.onmousemove=function(evt){ mx=(ie4||ie5)?event.clientX:evt.pageX; my=(ie4||ie5)?event.clientY:evt.pageY; } function getidheight(id){ if(ns4)return id.clip.height; if(ie4||ie5)return id.clientHeight; if(w3c)return id.offsetHeight; } function getidwidth(id){ if(ns4)return id.clip.right-id.clip.left; if(ie4)return id.clientWidth; if(w3c)return id.offsetWidth; } window.onload=function(){ windowloaded=true; conmenu=(ns4)?document.layers['conmenu']:(ie4)?document.all['conmenu']:document.getElementById('conmenu'); conshadow=(ns4)?document.layers['conshadow']:(ie4)?document.all['conshadow']:document.getElementById('conshadow'); if(ns4){ conshadow.clip.height=conmenu.document.height; conshadow.clip.width=conmenu.document.width; conmenu.clip.bottom=getidheight(conshadow); }else{ if(ie4||ie5)conshadow.style.filter="alpha(opacity=50)"; if(ns6||!ie4||!ie5)conshadow.style.MozOpacity=.5; conshadow.style.height=getidheight(conmenu); conshadow.style.width=getidwidth(conmenu); } //ADD OTHER WINDOW ONLOAD EVENT HANDLER SCRIPTS/COMMANDS HERE } window.onresize=function(){ if(ns4)setTimeout('history.go(0)',200); //ADD OTHER WINDOW RESIZE HANDLER COMMANDS/SCRIPTS HERE } </script>