By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,253 Members | 1,652 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,253 IT Pros & Developers. It's quick & easy.

Code to disable Print and Save As

P: 3
i need a code to disable user print and save as.if there is any javascript plz help me.last 1 month i need this code.the end user never save my pages and print my pages including text image
Jul 16 '06 #1
Share this Question
Share on Google+
15 Replies


P: 3
i need disable save as javascript
Jul 16 '06 #2

sashi
Expert 100+
P: 1,754
Hi Baranitharan,

i have seen right click disable kind of codes around.. if you need a faster solution, you try looking in Google.com.. or else you can post your code segment on your next post and we will help you to validate your code.. take care..
Jul 16 '06 #3

sashi
Expert 100+
P: 1,754
Hi Baranitharan,

check out the below code.. hope it helps you to get started with.. good luck my fren.. :)

no right click for images..
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript"> 
  2. <!--
  3. function noway(go) { if 
  4. (document.all) { if (event.button == 2) { alert(popup); return false; } } if (document.layers) 
  5. { if (go.which == 3) { alert(popup); return false; } } } if (document.layers) 
  6. { document.captureEvents(Event.MOUSEDOWN); } document.onmousedown=noway; 
  7. // --> 
  8. </script>
  9.  
no right click for source code..
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript1.1"> 
  2. <!--
  3. var debug = true; function 
  4. right(e) { if (navigator.appName == 'Netscape' && (e.which == 3 || e.which 
  5. == 2)) return false; else if (navigator.appName == 'Microsoft Internet Explorer' 
  6. && (event.button == 2 || event.button == 3)) { alert('This Page is fully 
  7. protected!'); return false; } return true; } document.onmousedown=right; if (document.layers) 
  8. window.captureEvents(Event.MOUSEDOWN); window.onmousedown=right; 
  9. //-->
  10. </script>
  11.  
Disable Copy and Paste.
Add the following html code to your BODY tag:
Here is how your BODY tag may look once implimented:
Expand|Select|Wrap|Line Numbers
  1. <body bgcolor="#FFFFFF" ondragstart="return false" onselectstart="return false"> 
  2.  
Expand|Select|Wrap|Line Numbers
  1. ondragstart="return false" onselectstart="return false"
  2.  
Jul 17 '06 #4

Banfa
Expert Mod 5K+
P: 8,961
baranitharan - I do not believe there is anyway to do what you want, File -> Save As and File -> Print are functions of the browser that you have no control over as they are not part of any web standard (i.e. HTML, Javascript, CSS etc). They are things that the browser designers put in because they thought they might be useful.

sashi - the things you suggest are worst than useless IMO because they are not deterant to someone who knows what they are doing, all the do is make a site a little more irritating to use.


If you are trying to prevent someone copying something you are publishing on the web then there is only 1 answer, don't publish it. Remember just by displaying it in there browser most people already have a copy of you item in there browser cache which is easy enough to access.
Jul 17 '06 #5

P: 3
thanks sashi. i am try you sample code...

Hi Baranitharan,

check out the below code.. hope it helps you to get started with.. good luck my fren.. :)

no right click for images..
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript"> 
  2. <!--
  3. function noway(go) { if 
  4. (document.all) { if (event.button == 2) { alert(popup); return false; } } if (document.layers) 
  5. { if (go.which == 3) { alert(popup); return false; } } } if (document.layers) 
  6. { document.captureEvents(Event.MOUSEDOWN); } document.onmousedown=noway; 
  7. // --> 
  8. </script>
  9.  
no right click for source code..
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript1.1"> 
  2. <!--
  3. var debug = true; function 
  4. right(e) { if (navigator.appName == 'Netscape' && (e.which == 3 || e.which 
  5. == 2)) return false; else if (navigator.appName == 'Microsoft Internet Explorer' 
  6. && (event.button == 2 || event.button == 3)) { alert('This Page is fully 
  7. protected!'); return false; } return true; } document.onmousedown=right; if (document.layers) 
  8. window.captureEvents(Event.MOUSEDOWN); window.onmousedown=right; 
  9. //-->
  10. </script>
  11.  
Disable Copy and Paste.
Add the following html code to your BODY tag:
Here is how your BODY tag may look once implimented:
Expand|Select|Wrap|Line Numbers
  1. <body bgcolor="#FFFFFF" ondragstart="return false" onselectstart="return false"> 
  2.  
Expand|Select|Wrap|Line Numbers
  1. ondragstart="return false" onselectstart="return false"
  2.  
Oct 15 '07 #6

acoder
Expert Mod 15k+
P: 16,027
Welcome back, baranitharan. Whoa! 15 months after your original post!
thanks sashi. i am try you sample code...
Listen to the advice from Banfa. JavaScript cannot disable these things. What you should consider is why you want to do this in the first place. If it's to protect images, just watermark them. Everything appears in the cache anyway, so disabling Save As has no effect on someone that is determined enough.
Oct 15 '07 #7

P: 4
How to close open/save/cancel dialog box in IE 8 when user click on some button.

please sugest its urgent.
Mar 12 '10 #8

acoder
Expert Mod 15k+
P: 16,027
So you have a dialog open and you want to close it by clicking a button? or did you want something else?
Mar 15 '10 #9

P: 4
i need to bypass that open /save/cancel when i will click to open pdf in my web application how can i do that using some code or somewhere else./
Mar 15 '10 #10

acoder
Expert Mod 15k+
P: 16,027
If it's a browser functionality, you'll have to check the browser settings.

Do you want the PDF file to display in the browser without a dialog box or do you want to force a download?
Mar 15 '10 #11

P: 4
basically i have an application which will generate a consolidate pdf for all the user information at last page when user click on a button, i m calling window.open method to open that pdf in a new window,

it is working fine in IE 6 and IE 7

but in iE 8 its is opening addition popup that is open/save/cancel ,i want to avoid that using some code not using browser setting.
Mar 15 '10 #12

gits
Expert Mod 5K+
P: 5,390
you might try to add a Content Disposition header with inline and filename before sending the pdf from the server ...

kind regards
Mar 15 '10 #13

P: 4
can u just tell me where i need to put this code.. in java file or in JSP...
Mar 15 '10 #14

gits
Expert Mod 5K+
P: 5,390
you will probably have a line where the pdf is send/printed in your code? probably it will be located in a jsp-page? ...
Mar 15 '10 #15

tsubasa
P: 64
I think I saw the solution in the MSDN Developer center, but I can't recall what the subject was under.

-Tsu
Aug 20 '10 #16

Post your reply

Sign in to post your reply or Sign up for a free account.