Hello, Is there anyway to prevent people from downloading an HTML document from my website using JavaScript or some other client-side programming language? For example, my page is located at: "http://mysite.com/dir/page.html", how can I prevent someone from downloading that page (by right clicking the link > Save Target As...)? P.S. I have to do this using JS or some other client-side language as this is on a free host that only allows HTML, so NO PHP, ASP, .htaccess,...
It's not possible to prevent people from downloading pages from your website, since basically, that's all a browser does. You can make it hard by using JavaScript, but it won't stop people who are determined. For example, I can just use wget to download pages as files. So if you're trying to hide something, don't expect it to be very secure.
http://www.programmingtalk.com/showthread.php?t=21985 http://www.rapworlds.com/forums/showthread.php?p=1241372 Just forget it, seriously...
Hi, I will have to say "YES" may be it is possible. I know some seniors here has said otherwise but still cant help it. I have to say yes it is possible to almost hide (if not completely hide html). What can be done is to have a HTML page only include a javascript file example: xyz.js In that xyz.js file the code only call a php file in Javascript tag passing document.url as a parameter. Now finally that php file will output the HTML contents in javascript document.write format. Now you can add additional check to that php file by checking document.url passed as parameter and also checking the HTTP referer. HTTP referer and document url should be valid for your server inorder for php to output document.write otherwise HALT. If a person will try to save the page, he will save HTML page with a xyz.js which also has nothing. If he tries to call php file it wont work until and unless he fakes referer (which I am not saying is impossible). So inshort it will be extremely difficult to get the code. You can make it further hard by using random parameters for each request/connection pair to know that for a request of your HTML page, JS is issued and is never directly called and to further ensure that for a single request of HTML page js is served single time. I think it will work to some extent. Experts please tell me your thoughts.
No way. You can reverse engenering any .js out there and retrieve PHP code or whatever. I can send you by email any html of any site out there...
It is great offer Cody, can I please PM you the link. i have tried several times but I couldnt get into the JavaScript code. I am not interested in the code, I am interested in knowing how they are blocking their HTML source and how it can be broken. Just to add, I never claimed it will make it impossible. I said it will make it extremely difficult.