Forum Moderators: open

Message Too Old, No Replies

Right Click POP-UP

         

webboy1

10:15 am on Apr 16, 2002 (gmt 0)

10+ Year Member



Can someone tell me how to make a POP UP box appear for both a normal mouse click and a right click?

<added from another thread>

Its actually an alert box i mean.....not a POP box.

Regards

Webboy

(edited by: NFFC at 10:44 am (utc) on April 16, 2002)

BlobFisk

11:51 am on Apr 16, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This should do the job for the right-click, but won't normal click also spawn the alert-box for link clicks also?


<script language="JavaScript" type="text/javascript">
<!--
var message="Your Message";

function clickIE() {if (document.all) {alert(message);return false;}}
function clickNS(e) {if
(document.layers¦¦(document.getElementById&&!document.all)) {
if (e.which==2¦¦e.which==3) {alert(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
// -->
</script>

joshie76

12:32 pm on Apr 16, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



IE and NN6(.2?) both support the oncontextmenu event (right click menu) - so you could do it like so for those browsers:

<script>
function myPopup()
{
alert('my pop up message');
}
</script>

<body onclick="myPopup()" oncontextmenu="myPopup();return false">

(return false cancels the right click menu)

Josh