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 Disable view sources in web Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Disable view sources in web" Watch "Disable view sources in web" New topic
Author

Disable view sources in web

Sophia Choi
Ranch Hand

Joined: Mar 22, 2002
Posts: 106
Since I need some info shown on web, the users can print it and sign a signature back to office. I don't want anyone who view the source and paste it into an editor and change the data and reprint it.
Does anyone know how to disable view source (View->View Source in toolbar or right click of a mouse) after displaying data from JSP ?
Chris Baron
Ranch Hand

Joined: Mar 21, 2003
Posts: 1049
Hi Sophia,
generally, the page the browser shows is on the clients computer! And the user can look at it's sourcecode...at the latest in the Temporary-Internetfiles-Directory, but...
your displaying page could contain something like this:

Then pack it in a Frameset.
But i wouldn't guarantee you this to be safe, also because some funky browsers may be unable to interprete margin for <body> correctly
cb
[ May 07, 2003: Message edited by: Christian Baron ]
Andy Bowes
Ranch Hand

Joined: Jan 14, 2003
Posts: 171
You can disable the right mouse button click by using a little piece of JavaScript see here for an example Codelifter.com - norightclick
I think disabling the menu option is a bit harder. You could try using a frameset which only includes a single frame that has the source as your page then when the user clicks on the View/Source option they would only see the source code of your frameset. [NB You would also need a bit of JavaScript at the top of your page to ensure that the users cannot view it without going through the frameset i.e. check the parent of the current window]
I personally don't like doing this as the Right Mouse button is used for more than just viewing the source code but if it is essential for you application give it a try.
HTH
Andy Bowes


Andy Bowes<br />SCJP, SCWCD<br />I like deadlines, I love the whoosing noise they make as they go flying past - Douglas Adams
Chris Baron
Ranch Hand

Joined: Mar 21, 2003
Posts: 1049
@andy

You can disable the right mouse button click by using a little piece of JavaScript

But this is useless if you switch off JavaScript
in the browser-settings
cb
Andy Bowes
Ranch Hand

Joined: Jan 14, 2003
Posts: 171
True
Sophia Choi
Ranch Hand

Joined: Mar 22, 2002
Posts: 106
Hi Andy,
You are right if I use the frameset. I can see the frameset source from View-> ViewSource in the toolbar. But when I use right-clicked mouse inside the content of each frames, I can see its content.
Would you like evaluate a bit about how to disable them in JavaScript ?
Thanks a lot.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
It IS IMPOSSIBLE, this discussion should be in the HTML Javascript forum,
The only safe way is to not sgow it and burn the computer to a lump of plastic it was crated on. The reaon why is there are countless programs out there that can get the source code. Antio right scrips do not work if javascript is disabled, removing the tool bars does not work in all browsers. THe code is in the temp file. A person can just look through it and find it. They can save the page, they can priont screen the page. The list goes on and on....
If you want to waste your time with this then do a search online for disable right click, but it does not work for certain mice with number of buttons, OH and the great thing is some people have hot keys on their keyboard that show the source.
You can do a trick that makes everything look jumbled when selected by taking all of the spaces and replacing them with jumbled letters that match the background. They will look like spaces, but they are actaully text.
Stuff that is displayed on a browser is open source.....The way it should be....My 2 Cents
Eric
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

Originally posted by Andy Bowes:
You can disable the right mouse button click by using a little piece of JavaScript see here for an example Codelifter.com - norightclick
I think disabling the menu option is a bit harder. You could try using a frameset which only includes a single frame that has the source as your page then when the user clicks on the View/Source option they would only see the source code of your frameset. [NB You would also need a bit of JavaScript at the top of your page to ensure that the users cannot view it without going through the frameset i.e. check the parent of the current window]
I personally don't like doing this as the Right Mouse button is used for more than just viewing the source code but if it is essential for you application give it a try.
HTH
Andy Bowes

You can use SHIFT + F10 on windows machine to emulate right click. Believe me, it is *NOT* possible. I agree with Eric on this one -

Stuff that is displayed on a browser is open source.....The way it should be....My 2 Cents
Eric

- Manish
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Moving to the HTML forum.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61214
    
  66

As Eric said, this simply cannot be done.
You can be rude and disable right-clicks, and try to pervert the browser window all you want, but when it comes down to it, the source needs to be downloaded to the computer and is available to anyone who wants to put even a little effort into getting at it.
So why annoy your users trying to?
hth,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ivan Tamayo
Ranch Hand

Joined: Aug 13, 2001
Posts: 49
This question is equivalent to:
"I�ve sent a file to a friend and i dont want him to see it"
Since the file is ALREADY in his computer, there�s no way you can limit his rights.
Any *protection* you put in the source code is irrelevant, remember the HTTP protocol
Michael L. Zhang
Ranch Hand

Joined: Jul 06, 2003
Posts: 33
I downloaded htmlsource viewer from http://www.goorbis.com/, this tool can view html and javascript easily no matter what you do in your code.

There is another tool IEWatch at
http://www.iewatch.com/index.html#

I just want to know which one is better, and is there any other wonderful tools on the market?

Can someone help me choose the right tool? I need view the javascript file as well as html source.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
There are tons of site grabbers out there that you point it at a site and it starts to download everything.

The easiest thing to do is to goto the site. Do a view source and look for the js files. Type that link into the browser and it asks you to save it. Then you can look at how they do the code.

My 2 cents,
Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Disable view sources in web