Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1606
  • Last Modified:

How can i prevent View source in browser?

How can i prevent View source in browser? Without JavaScript.
0
elluriramakrishna
Asked:
elluriramakrishna
  • 6
  • 3
  • 2
  • +8
1 Solution
 
psogaaCommented:
I don't think it's possible...
0
 
yyyannagCommented:
you have to use javascript, in order to turn off the right click options, or using HTML.encode method.

You can't do it only with HTML.
0
 
dij8Commented:
It can't be done.  There are tricks, like the right click disabling, but this doesn't help.  You then only need to go to the view menu.  If the menus are gone then on a Windows machine with a windows keyboard you only need to press the context sensitive menu button.  And if even that fails then you only need to go to your cache.  A page needs to be downloaded to be seen.  And in downloading it the user gets the code for free.  There is no way around this.

If your code is so special that it can't be shared then don't put it on the web.  That is the only real answer.  The next closest thing is to turn your scripted functions into server side compiled components and run them on a server that supports what you have written.

Another lame idea but one that makes it just a fraction more difficult than right click/view source is to have your scripts as external files.  But then a person only needs to look at where your scripts are stored (in your source code) to be able to download them directly.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
DreamMasterCommented:
All there is, are tricks to make it harder to view the source-code...but there are many ways to get around these tricks....

And the most forgotten one is that the page you visit..is in your history, as soon as you want to view the source go to the specific page in your history and open it in notepad...there you have your source...

So what I'm trying to say, do not try to hide your source...when you do, it will make people more curious what the reason is that you hide your source and will make them want to view it even more...and trust me...when they want...they can!

Max.
0
 
dorwardCommented:
It is absolutly 100% impossible.

The tricks which make it harder for people to get at it are easily bypassed and tend to lock out other features that people want to use (such as opening a link in a new window).
0
 
emelinCommented:
http://continue.to/hope/ deals with this, it's a pretty good summary of what can be done and why there's no use trying. :)
0
 
COBOLdinosaurCommented:
LOL   At least once a week ... and emelin already posted my favourite link
on the subject.

If the browser has to render the code it has to be able to see it.  If the
browser can see it:  I can see it; I can take; I can post it;  and there
is nothing you can do to stop me.

You can go so far as to use a JAVA applet to generate the code so the is
nothing on the source page except the code to load the applet.  I will
still be able to get the code.

Try anything you want.  When you think you have found a way to hide the
source do this:

Using IE5+ type this into the address bar

javascript:str=document.documentElement.innerHTML;document.write('<textarea rows=20 cols=60>'+str+'</textarea>');

The page has been replace with one containing a textarea with all the
code the browser used to render the page.

I don't know of any method, including generation of the code using an applet,
that can prevent capture this way. Any HTML generated by JavaScript is
shown after generation instead of the JavaScript code even if the code
is sourced in.  Instead of seeing the JavaScript you see the result of it.

However if someone comes up with something, I will just defeat it another
way.  This method does not capture the source code,  It captures what the
browser sees and executes to render.  If I can't see it this way then
IE5 can't see it either, and therfore cannot render the page.

Now course the whole page can be done with an applet or flash, but
then it is compiled code.  It is not a WEB page any more.  It is a
browser appliction that requires the user to allow compiled code on
their computer. That is something that more and more users are refusing
to do because it opens them up to viruses and trojan horses.

BTW if you are have trouble with geting pure text off of a page
because they have made it difficult to cut and paste just change
innerHTML to innerText and it will put all the pure text content
into the text area.

Cd&
0
 
COBOLdinosaurCommented:
BTW, welcome to EE.  Sorry your first question does not have a positive answer.

Cd&
0
 
Ernest022699Commented:
emelin: The link doesn't work for me.  Is something missing?  Thanks!
0
 
DreamMasterCommented:
Duplicate account??

Max.
0
 
dog78Commented:
Well said, COBOLDinosaur.

By the way, nice trick.
0
 
kagthaCommented:
This doesnt solve it..but it makes it hard,

1st page of your site has to be viewable (you may put the no right click script on it..but they can still view)

link all other pages as pop-up windows (there are ways to make them maximize as big as users screen..tell me if you want that code
like:   <a href="click me" onClick="MM_openBrWindow('yourpage.html','','width=400,height=400')">click me
</a>

now insert that same no right click script on the page as earlier linked to in this discussion by emelin


The only way to get the source is to read the home pages html..find where it links to next page and paste it manually into the address bar of a fresh browser.
0
 
dorwardCommented:
kagtha's solution just makes the site unusable to people with JavaScript disabled or unavailable to them and can very easily be bypassed by viewing the contents of the browser's cache.
0
 
dij8Commented:
kagtha's solution is just another trick that is extremely easy to bypass.  If you have a Windows keyboard try pressing the "context sensitive menu" button (the one on the right with the arrow and drop-down menu).  And then select view source.  Done.  And that is before you go to the browser cache.

There is only one gauranteed way of stopping people from viewing your source.  DON'T PUT IT ON THE WEB!
0
 
COBOLdinosaurCommented:
Or just shift+f10 still gives you the menu.  Abad solution unless you want to prevent the viewing of the source by convincing users that they should not use the site because it uses obnoxious rendering techniques.

Cd&
 
0
 
COBOLdinosaurCommented:
Hmmm... no one has answered yet...

Q:"How can i prevent View source in browser? Without JavaScript. "

A:<no JavaScript required>

1. Put source on a CD which is copy protected.  
2. Put CD in a steel box.
3. Use duct tape to attach the steelbox to an armed nuclear warhead.  
4. Connect the detonator of the device to a motion detector that will detonate if there is any movement within 10 metres.

Now let's see anybody get that code. :^P

Cd&
0
 
emelinCommented:
Ernest,
(+ everybody else unable to open the link I submitted)
try http://webhome.idirect.com/~bowers/copy/copy1.htm instead!
0
 
COBOLdinosaurCommented:
To close this out, I will be making a recommendation to CS
in about a week.  I would appreciate any comments from the
participants on how it should be disposed of.

Cd&
0
 
dij8Commented:
I think I covered it first for the "it can't be done" statement (psogaa was guesing and wasn't really stating an answer).
0
 
COBOLdinosaurCommented:
It is time to clean this abandoned question up.  

I am putting it on a clean up list for CS.

<recommendation>
points to dij8

</recommendation>

If anyone participating in the Q disagrees with the recommendation,
please leave a comment for the mods.

Cd&
0
 
Computer101Commented:
Comment from dij accepted as answer.

Thank you
Computer101
Community Support Moderator
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 3
  • 2
  • +8
Tackle projects and never again get stuck behind a technical roadblock.
Join Now