disable view source ...

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
HormonX
Forum Commoner
Posts: 50
Joined: Tue Dec 10, 2002 7:43 pm
Location: Toronto

disable view source ...

Post by HormonX »

Does anyone know if there is a way to disable 'view source'? I don't mean getting rid of right-click option :).

Please let me know if there is a way of doing that.

Greg
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Short answer? It's impossible.

Long answer? ...Google.com has information on the long answer.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

technically, as long as a browser can display the page, the page's source can be seen and read. You can ~encrypt the data inside Javascript, but that only deters the casual person. Can we ask why you want to disallow viewing your source?
myleow
Forum Contributor
Posts: 194
Joined: Mon Jun 21, 2004 7:05 pm
Location: California

Post by myleow »

because its not open source. :twisted:
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

well, you should realize that theres really nothing you can do to prevent it.

the average person prob couldnt get past a right click disabled or a javascript encrypting, but the average user prob has no care to read your html source either.


the person who would have a desire to read your source, can prob get around whatever you do fairly easily.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

This may be an odd question - but how is a project not being open source an encouragement to obscure html markup? I mean all your markup in the end is going to be standard HTML. Any decent author could replicate the display in their browser within a short time.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

and if I was really hell-bent on stealing your HTML I could use use get under Linux and there's nothing you could do against that.

Why would you be concerned about HTML? Javascript - I believe there are things like encoders for it, but that's as far as it goes. You have to live with the fact that whatever you put in front of the public's eyes, it'll be looked at.
HormonX
Forum Commoner
Posts: 50
Joined: Tue Dec 10, 2002 7:43 pm
Location: Toronto

Post by HormonX »

well ... it was just curious if it was possible. As you guys mentioned nothing can be done to totaly hide the HTML code ... and there is no good reason for that as well.

thanx guys

Greg
xudzh
Forum Commoner
Posts: 48
Joined: Sat Feb 19, 2005 6:22 pm

Post by xudzh »

THIS IS JUST AN IDEA:

1. create a file called dom.htm

2. In the page that the user would call, say index.htm, use window.open (make sure to somehow get pass the popup blocker) to open dom.htm.

3.have dom.htm first call window.opener.document.write() to erase the page source of index.htm . THEn use DOM functions to create ur original page, using createElement.(i forget the exact function name) then window.close();

Now when a user tries to view index.htm's page source, he/she will find it empty.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the viewing will not be affected by Javascript.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

If you try and hide code of any sort it often makes users more interested in what is going on and will encourage people to dig around, especially on a web site with technical people on it. Leave the HTML visible and people will generally ignore it. If you don't want javascript readable you can encode it with encoders but I read an article somewhere (cannot remember where unfortunately) which discussed these and the came up with the result that they are fairly easy to crack. The main reason for encoding the Javascript is to compress it for quicker download times.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

xudzh wrote:THIS IS JUST AN IDEA:

1. create a file called dom.htm

2. In the page that the user would call, say index.htm, use window.open (make sure to somehow get pass the popup blocker) to open dom.htm.

3.have dom.htm first call window.opener.document.write() to erase the page source of index.htm . THEn use DOM functions to create <span style='color:blue' title='ignorance is bliss'>your</span> original page, using createElement.(i forget the exact function name) then window.close();

Now when a user tries to view index.htm's page source, he/she will find it empty.
I disable Javascript with one click in my browser. And what if people have Javascript disabled by default?
xudzh
Forum Commoner
Posts: 48
Joined: Sat Feb 19, 2005 6:22 pm

Post by xudzh »

It's just an idea i came up. Never really tried it. :wink:
Post Reply