Forum Moderators: open

Message Too Old, No Replies

suppressing "view source"?

protecting my work

         

meingallsphp

8:07 pm on Dec 9, 2006 (gmt 0)

10+ Year Member



Is there a way to trap the view source command (both from the right mouse click and from the view menu) so that I can prevent others from seeing the html source code for certain pages on my website?

digitalghost

8:41 pm on Dec 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nope. Disabling functions simply annoys people and offers very little protection. Anyone with the slightest bit of knowledge will circumvent your efforts. You can cloak, but that's a whole 'nother can of worms.

ronin

9:20 pm on Dec 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you want to hide a piece of code from most people - but recognise that the most determined will always be able to get it regardless - you can always try surrounding your code with:

document.write (' ... ');
document.write (' ... ');

and then sticking it in an external javascript file and referencing the file from the html document.

A lot of people won't be able to figure out where to find the code, but anyone familiar with building websites will find it in a couple of seconds.

Robin_reala

11:17 pm on Dec 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



And it’ll be totally inaccessible to users without Javascript, and won’t be read by search engines.

HTML is an interpreted format and as such has to be sent to the user’s browser as its source. Any attempts to obfuscate it are just that, only attempts. Your real IP is in the logic behind the site, and not the front-end HTML.

ronin

7:55 pm on Dec 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I agree with every word you say wholeheartedly, Robin_reala. But just out of curiosity, who are these users without javascript? Because I still hear a lot about them even in 2006, but I haven't seen them since 1995.

digitalghost

8:14 pm on Dec 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Apps like Prefbar make it really easy for people to toggle JS on and off. It's much more likely that the folks that want to steal source are a little more clued up than Joe surfer.

[edited by: digitalghost at 8:23 pm (utc) on Dec. 11, 2006]

DanA

8:17 pm on Dec 11, 2006 (gmt 0)

10+ Year Member



I use the extension noscript (one of the most popular Firefox add-on!)

Robin_reala

11:06 pm on Dec 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Some people are stuck behind filtering firewalls that strip out JS. Some people don't want (or need) the fancy effects that JS can provide - maybe they’re running old hardware and enjoy the speedup. Some people run assitive technology that doesn’t cope with JS DOM manipulation well (i.e. nearly all current screenreaders) and turn it off for consistency. Some people use IE and actually follow Microsoft’s security recommendations, which in the case of unpatched bugs usually is “turn off scripting”.

For whatever reasons, we regularly see anywhere up to about 10% of users without Javascript available. That’s too many to throw away for the sake of an easily defeated anti-copying measure.

topr8

11:18 pm on Dec 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



>>who are these users without javascript?

as you kow the most important users without javascript are the search spiders, so in this case using javascript would be insane

bhartzer

11:21 pm on Dec 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can disable the right-click view source like others have mentioned. But, if they want the source code they can get it.

The only other way is to cloak the page.

Don't forget to tell the search engines not to cache the page (use the noarchive tag), which helps as well.

ronin

10:47 am on Dec 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



the most important users without javascript are the search spiders, so in this case using javascript would be insane.

Well, not always. Among the navigation tools I employ on the pages of my site I use javascript-powered forms, but the whole html code for the form is stored in an external .js file. Why? Because I don't think it's necessary for the spiders to read through the same kilobyte of code on every page they visit. Plus, it's a long and general menu, so it would make the parsed content less specific.

But this is slightly off the point - I don't put that html code in an external .js file in order to "hide" it from humans, I do it merely as a matter of convenience.

As we are pretty much all agreed, attmpting to hide html code is a bit of a lost cause.

Darkelve

11:03 am on Dec 12, 2006 (gmt 0)

10+ Year Member



I'm wondering: why exactly do you want to hide it? What's the purpose for it. Because maybe there are other, better, ways than hiding the code to achieve that purpose.

[edited by: encyclo at 11:35 am (utc) on Dec. 12, 2006]
[edit reason] tidying up [/edit]