Solved

How can i prevent View source in browser?

Posted on 2001-07-30
21
1,588 Views
Last Modified: 2008-03-04
How can i prevent View source in browser? Without JavaScript.
0
Comment
Question by:elluriramakrishna
  • 6
  • 3
  • 2
  • +8
21 Comments
 
LVL 2

Expert Comment

by:psogaa
ID: 6333280
I don't think it's possible...
0
 
LVL 2

Expert Comment

by:yyyannag
ID: 6333376
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
 
LVL 10

Accepted Solution

by:
dij8 earned 50 total points
ID: 6333477
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
 
LVL 19

Expert Comment

by:DreamMaster
ID: 6333509
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
 
LVL 17

Expert Comment

by:dorward
ID: 6333577
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
 

Expert Comment

by:emelin
ID: 6334522
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6334637
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6334644
BTW, welcome to EE.  Sorry your first question does not have a positive answer.

Cd&
0
 
LVL 1

Expert Comment

by:Ernest022699
ID: 6349383
emelin: The link doesn't work for me.  Is something missing?  Thanks!
0
 
LVL 19

Expert Comment

by:DreamMaster
ID: 6349468
Duplicate account??

Max.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Expert Comment

by:dog78
ID: 6349911
Well said, COBOLDinosaur.

By the way, nice trick.
0
 

Expert Comment

by:kagtha
ID: 6349953
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
 
LVL 17

Expert Comment

by:dorward
ID: 6350254
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
 
LVL 10

Expert Comment

by:dij8
ID: 6351179
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6351672
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6351882
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
 

Expert Comment

by:emelin
ID: 6354789
Ernest,
(+ everybody else unable to open the link I submitted)
try http://webhome.idirect.com/~bowers/copy/copy1.htm instead!
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6537541
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
 
LVL 10

Expert Comment

by:dij8
ID: 6541151
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6616362
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
 
LVL 1

Expert Comment

by:Computer101
ID: 6616704
Comment from dij accepted as answer.

Thank you
Computer101
Community Support Moderator
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now