Author Topic: Better no right-click script in this post  (Read 7634 times)

0 Members and 1 Guest are viewing this topic.

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Better no right-click script in this post
« on: May 12, 2002, 07:51:33 PM »
The current script included in 1.5 beta doesn't work in Mozilla 1.0 RC2 or Netscape 6.2.2.  It also displays the alert() twice.

Code: [Select]

<SCRIPT LANGUAGE="Javascript">
<!--
// ***********************************************
//  http://www.cgiscript.net/scripts.htm
// ***********************************************
var isNS = (navigator.appName == "Netscape") ? 1 : 0;
var EnableRightClick = 0;
if(isNS)
document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);
function mischandler(){
  if(EnableRightClick==1){ return true; }
  else {return false; }
}
function mousehandler(e){
  if(EnableRightClick==1){ return true; }
  var myevent = (isNS) ? e : event;
  var eventbutton = (isNS) ? myevent.which : myevent.button;
  if((eventbutton==2)||(eventbutton==3)) {
    alert('© Copyright {site_name}');
    return false;
  }
}
function keyhandler(e) {
  var myevent = (isNS) ? e : window.event;
  if (myevent.keyCode==96)
    EnableRightClick = 1;
  return;
}
document.oncontextmenu = mischandler;
document.onkeypress = keyhandler;
document.onmousedown = mousehandler;
// document.onmouseup = mousehandler;
//-->
</script>


This script belongs in the header.html template and has been tested in Mozilla, Netscape and IE.  I don't have Opera to try it.

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Better no right-click script in this post
« Reply #1 on: May 12, 2002, 08:17:09 PM »
Hi Chris,

thanks, i will test it !  :D

Greets Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search