File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes disabling of Internet Browser options Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "disabling of Internet Browser options" Watch "disabling of Internet Browser options" New topic
Author

disabling of Internet Browser options

Avinash Tiwari
Ranch Hand

Joined: Sep 20, 2006
Posts: 50
Hi I need to disable the option like CTRL+P from my Internet Browser like when the user goes to File menu on Internet Browser and clicks on Print , the action print shud not take place...This thing using java how can we do...


Work hard and rest not till the job is done....
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


This thing using java how can we do

We can't. You might be able to do this with JavaScript, but the user might disable JavaScript.

A general rule of thumb is if you application requires you break the normal operation of another application, you should possibly rethink how your application works. I tend not to visit sites again if they use scripts to change the behaviour of my browser.
[ October 17, 2006: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3636
Originally posted by Paul Sturrock:
I tend not to visit sites again if they use scripts to change the behaviour of my browser.


True, if you deviate from the standard flow of operation, user will not be happy.

Think about other options rather then disabling CTL + P � you can display message on the page prompting user that do not use Print option of the browser.


My blood is tested +ve for Java.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
More interesting is the question: why do you want do disable printing anyway?
Avinash Tiwari
Ranch Hand

Joined: Sep 20, 2006
Posts: 50
The reason for disabling the Browser option is because lets suppose the browser is displaying some confidential information and the user wants that information on screen but not on paper or print..For eg his signature....Thats why the need is to display the information with every control of browser enabled but restricting the use of any control which might put the information on paper...
Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3636
Originally posted by Chapree Mamoo:
The reason for disabling the Browser option is because lets suppose the browser is displaying some confidential information and the user wants that information on screen but not on paper or print..For eg his signature....Thats why the need is to display the information with every control of browser enabled but restricting the use of any control which might put the information on paper...


There are many ways to take a print of a webpage

(1)File --> Print
(2)Control + P
(3)Print Button on Toolbar
(4)Right Click --> Print
(5)Print Screen --> Paste in Paint --> Print
(6)Use HttpClient to make request and print the response
(7)��

How will to stop user from doing this?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

That is an unmeetable requirement. Suppose my browser told me that I could not print a document and I really wanted to print it its easy to get round my browser trying to stop me. I could turn off JavaScript (assuming the JavaScript is used to prevent printing). I could download the page and open it in some other application. I could view the source and print that etc.


Think about other options rather then disabling CTL + P � you can display message on the page prompting user that do not use Print option of the browser.

True Chetan Parekh. Maybe its just me but when sites do this sort of thing I tend not to visit them twice.
Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3636
Originally posted by Paul Sturrock:

True Chetan Parekh. Maybe its just me but when sites do this sort of thing I tend not to visit them twice.


You can't make all the people all the time happy.
Avinash Tiwari
Ranch Hand

Joined: Sep 20, 2006
Posts: 50
Lets suppose what's desired is something like this :
The signature is in image format and the need is , not in any case let that image appear on print/paper/file.
But the pop-up messages saying Print is an invalid option are not to be used....
Then we will have to restrict the options through coding..How will we go about in this case then....
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

It can't be done. If you make the image publically available it is printable. You can make it difficult to print by trying to break the printing funtionality available in a browser (though as I've pointed out, this won't stop them using an application other than a browser to print the image). If the user is determined enough they will be able to print the image. It does beg the question, if the image is sensitive, why is it being amde publically available at all?
Avinash Tiwari
Ranch Hand

Joined: Sep 20, 2006
Posts: 50
Lets say the image is a digital signature..which is required for entering into certain application...but is not required to be printed for security/hacking purposes....
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Anyway, this has nothing at all to do with Java. I'm moving it to "HTML and JavaScript", where they will tell you the same stuff.


[Jess in Action][AskingGoodQuestions]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

The only way to keep it from being printed is to never send it to the browser.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Originally posted by Chapree Mamoo:
The reason for disabling the Browser option is because lets suppose the browser is displaying some confidential information and the user wants that information on screen but not on paper or print..For eg his signature....Thats why the need is to display the information with every control of browser enabled but restricting the use of any control which might put the information on paper...


Put this information in an unique styled block, for example: class="confidential" and add this to the css:



Then this field will be removed from the view to print. Or, if you don't want to shuffle the layout, then use {visibility: hidden;}


Oh, this doesn't prevent the user from hitting PrintScr, pasting it in a graphic editor and printing it as an image ...
[ October 17, 2006: Message edited by: Bauke Scholtz ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: disabling of Internet Browser options
 
Similar Threads
how to disable autocomplete for password
closing windows
Printing Html
Saving word document in browser doesn't work
Internet Explorer browser version