free
This is our archive, please go to the main forum page for the latest discussions and news about free web hosting.


JavaScript Question

sana
November 1st, 2000, 15:27
How can I block users from viewing my source code when they right click on a window? I can do an "onmouseclick" but that blocks a left click as well.

(To see what I mean, try this:
Click on any song from the list at http://ww.sma----s.com/audio/index.cfm?Page=ShowTracks&Letter=F&Category=Smash_Hits&Choice=Category&ProductID=914&Open=2

Right click on the popup window and you get a JavaScript alert.)

How do I do that??

Luqman
November 1st, 2000, 15:57
You can find it at http://www.dynamicdrive.com

Gonzo
November 1st, 2000, 16:51
There is no way that I know of to hide your source code. That JavaScript is not going to stop anyone to look at your source code.

sana
November 1st, 2000, 16:53
Thanks, found the code at dynamicdrive!

Nick
November 1st, 2000, 17:19
Originally posted by Gonzo
There is no way that I know of to hide your source code. That JavaScript is not going to stop anyone to look at your source code.

Some site's use JScript that blocks you from using the keyboard and left mouse button. The only way to get it is to find the address of the popup which is most of the time very hard.

Koolguy
November 1st, 2000, 17:34
Don't do it, visitors don't like it

sana
November 1st, 2000, 18:23
Originally posted by Koolguy
Don't do it, visitors don't like it

Koolguy, the reason I wanted to do it was so that users couldn't check the source and file path of RealAudio files I was hosting on my server. Nothing annoying intended for the visitors.

Nick
November 1st, 2000, 18:38
Originally posted by sana
Originally posted by Koolguy
Don't do it, visitors don't like it

Koolguy, the reason I wanted to do it was so that users couldn't check the source and file path of RealAudio files I was hosting on my server. Nothing annoying intended for the visitors.

It doesn't matter what you were using it for. It will still piss people off...

sana
November 1st, 2000, 18:49
Well if people are pissed off that I'm not allowing them access to steal our RealPlayer files, then so be it. I really don't see why the audience we're targetting (just visitors interested in hearing music) would stop coming to the website on just that basis. :-)

Koolguy
November 1st, 2000, 19:43
There are cgi or php scripts which can stop a file from being viewed outside of your domain. This is a lot better becuase there is nuthing on the clients end.

cds
November 3rd, 2000, 12:21
Sana, I agree with you that you want to protect your files, but I have to agree with Koolguy that CGI/PHP is the way to go to do it.

Javascript is incredibly annoying, especially the script in question. A lot of the time, especially on faster connections, certain frames, or images get broken on the server feed. The only way to restore them is (gasp) right click and show image, or refresh. There is nothing more frustrating then popups! At the very least, just disable right clicking and dont make it popup anything.

PHP or PERL can be easily used to protect your links. Simply check the referering address, and make sure that they have come from your site. Then, just stream the media through the script as a server feed...not to hard to do. Check out http://www.hotscripts.com for some scripts that do just that...

Rodie
November 3rd, 2000, 15:59
Originally posted by sana
How can I block users from viewing my source code when they right click on a window? I can do an "onmouseclick" but that blocks a left click as well.

(To see what I mean, try this:
Click on any song from the list at http://ww.sma----s.com/audio/index.cfm?Page=ShowTracks&Letter=F&Category=Smash_Hits&Choice=Category&ProductID=914&Open=2

Right click on the popup window and you get a JavaScript alert.)

How do I do that??

There is *no* way for you to block your source code. There are millions of ways to get around those disable right click scripts, and most of them are not that complex. For starters, people could just chose "view/source" from the menu bar at the top of the screen. They could just save the document to their hard drive and open it up in notepad. Or they could just simply go into their cache and find the file.

And of course, your script does absoltuely nothing to my computer sicne I have a mac and macs only have a one-button interference. If people are smart enough to run a website that could steal URLs from your website then they are probably smart enough to know a little bit about how to get around in a browser. Not to mention the fact that you will really p*ss off left-handed visitors to your website who have the mouse buttons reversed (you'll disable their primary button since they'd have the buttons reversed). It's the opinion of a lot of webmasters that blocking your source code using javascript is not professional at all. A lot of them rank it right up there with putting background midi music on a website without a way to stop it. If you don't believe me, just go onto the newsgroup alt.www.webmaster and ask about a disable right-click script, and watch the flames that follow.

If your browser can display something, then people can already view the source of it. Just live with it.

Of course there are other, more effective ways to prevent people from stealing your stuff that other people on this thread have already pointed out. I'd suggest going in that direction. Stay away from java-script!

cds
November 3rd, 2000, 23:32
For an example of bandwidth and link protection on a working site using CGI/PHP, check out blueharvest.net. All of their videos use this scheme and are protected from the user...

CDS - *huge* starwars fan (hence the blueharvest example :))

DarkScorpious
January 16th, 2002, 19:26
If you really want to protect your files just go back to dynamicdrive and in that search type encrypt and it should give you results goto the source code encrypter and put in your pages html and javascript and whatever else in that block and encrypt it still people can get your encrypted code and unencrypte it with that same tool but not many people know of it hehehehehe

Dusty
January 16th, 2002, 19:34
Yes, the ones that don't know about it are the ones you don't have to fear stealing your code anyway.

1) Disabling right-clicks doesn't stop people from viewing your source-- at all.
2) There's more in the contextual menu than just "View Page Source".

Bruce
January 16th, 2002, 19:36
:eek:

Can we say 14 month old thread?

niv
January 16th, 2002, 19:40
Originally posted by Phrozen
:eek:

Can we say 14 month old thread?

14 month old thread

Dusty
January 16th, 2002, 19:42
Hell, it is. I thought it looked familiar, but these same question roll around so frequently. Who dug it up?... DarkScorpious, and it's not the first thread he's dug up. http://www.freewebspace.net/forums/showthread.php?postid=165840#post165840

I'd like at this point to rekindle my suggestion to modify the forum to automatically lock threads over a month old.

StormClouds
January 17th, 2002, 22:26
Dont put that on your site because people will think it is "Child Like" or a "Newbie Website":devious2:

sannie
April 9th, 2002, 10:55
This simple line blocks right-clicking on all my sites:

body oncontextmenu="return false;"

Don't forget to enclose that with brackets < > :)





  
  News · Search free hosts · Free file hosting · Free image hosting · Reviews · Forums · Related Links · Advertising Info · Contact Us


Copyright © 1996-2008 Per Olof Sandholm. All rights reserved. Privacy Statement

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum