Click to See Complete Forum and Search --> : Is it possible?
Detroit man
January 7th, 2003, 11:04 AM
Hi all!
Is there a way to disable the view source option when right-clicking on a web page?
Thanks for your time
columbus2003
January 8th, 2003, 05:13 AM
I have no idea to protect it.
But it is possible if you can use applet. In another way,
if you don't want to show your script, I suggest to
encript your script. OR first, save your script to another script file. and then include it by using following tag
<script language="JavaScript" type="text/javascript" src="yourscriptfile.js"></script>
Metaphor
January 13th, 2003, 07:47 AM
It's possible using one of the OnMouse functions in the body tag, and testing for the righthand mousebutton.
TheCPUWizard
January 13th, 2003, 08:21 AM
Depends on the level you want to protect the source....
If you just want to hide it from the casual observer, create a single frame page and render your content inside the frame.
Users who click on view source will see the definition for the frame layout.
Of course any and all methods to protect HTML source send to the client machine fail if the client writes a program to sent the request and reads and processes the response directly.
Metaphor
January 13th, 2003, 08:24 AM
That solution will only work if they use the View Source command from the View menu. If you rightclick on the content, and choose view source, you'll get the correct source. The easiest, and most userfriendly (insofar it's considered that users are considered to be morons who can't program) option is the one I posted. In my opinion.
TheCPUWizard
January 13th, 2003, 08:38 AM
Metaphor, I agree about the limitation of my solution as you pointed out, but I am wondering if you are intending to totally eliminate the context menu or just eliminate View Source?
If the latter, could you please post a snippet that would eliminate that but still allow things like add to favorites....
Metaphor
January 13th, 2003, 11:31 AM
Well. I don't have any actual code, but the theory works, and I've seen it in practice. As for the Add to favourites option, that can still be accessed from the Favourites menu when the rightclick contextmenu is hidden. Just like view source can be accessed from the view menu. There's, as far as I know, not a complete solution to hiding source, unless you serve content out of scripts, etc.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.