Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Disable Right Click,View source and save as

 
Ashish Agarwal
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to disable right click, Save as and view source in Netscape 6 and IE 5.5. Can anybody tell me how to do it.
TIA
Ashish Agarwal
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ashish
I'm not sure there is a reliable way to do that. I've seen some hacks but none that work in everything - do a search on this forum for previous discussions. The biggest problem is that there are multiple ways to do those things not using the mouse.
Dave
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd have to agree. I had a bit of a think and the solutions would definitely be "hacks". They wouldn't work well or consistantly or stably and you'd just end up annoying you users.
Unfortunately this is not what HTML is for and you'd essentially be "breaking the rules".
Also, you'de most likely have to rewrite your code from scratch every time a sub-version was released to keep it working.
One bad solution I came up with is to provide the relevant pages as non-printable PDF docs. The user could save the PDFs on their local machines but would not be able to view the "underlying content" or print the data or separate the pictures. It's a bit heavy tho...
Dave.
 
Ashish Agarwal
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friends,
Thanks for your replies,I have written some code where I'm disabling right mouse click and hiding the MenuBar altogether. I know there are ways to get around it but for novice users it will work. My problem now is that this is working for Netscape6.0 but not for IE5.5. For IE5.5 it show error that window.menubar is not an object. Can anybody help on this.
I have changed onClick to oClick in my code as Javaranch does not allow onClick to be posted. Plese make it onClick when u copy and paste the code.
--------------------------------------------------
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<script language="JavaScript">
window.menubar.visible=false;

function disableMenu(){
window.menubar.visible=false;

}
function enableMenu(){
window.menubar.visible=true;

}

</script>
</head>
<body bgcolor="#FFFFFF">
<script language="JavaScript">
document.oncontextmenu = function(){return false}
if(document.layers) {
window.captureEvents(Event.MOUSEDOWN);
window.onmousedown = function(e){
if(e.target==document)return false;
}
}
else {
document.onmousedown = function(){return false}
}
</script>
<form name=frm>
<input type=button name=btn value="Hide menubar" oclick='disableMenu()'/>
<input type=button name=btn value="Show menubar" oclick='enableMenu()'/>
</form>
</body>
</html>
--------------------------------------------------
Thanks
Ashish
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For IE5 and above you can add this to your body tag to prevent the right-click:
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<input type=button name=btn value="Hide menubar" oclick='disableMenu()'/>
<input type=button name=btn value="Show menubar" oclick='enableMenu()'/>
</form>
Quick question:
ummmm shouldn't the stuff in bold be onclick??
 
Reda Mokrane
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you are correct they should be but before your post Javaranch does not allow onclick to be posted.
[ January 10, 2002: Message edited by: Reda Mokrane ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah forgot about that..lol...and it says it above....duh...was not awake when I read that!
[ January 11, 2002: Message edited by: Al Ian ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic