Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to prevent user from browsing/viewing my web pages CSS or javascipt file or Images .What will be the best approach for this ?Please help me......
Posted
Comments
Abhijit Barua 21-Nov-11 7:05am    
Hi Rupanjana, U can check these link below..
http://www.astahost.com/info/tiiipi-hide-source-code-hide-source-code.html
You can hide, but better u use ajax where it suitable and do server side codding more.

You can't protect to download Javascript, CSS and Images from users.

But you can prevent or restrict few things like.

  • Image
    You can stop Right Click for saving/download Image by the user.
  • Javascript
    You can apply encryption/Minify Javascript to make more complicated your code to under stand by the end user.
  • CSS
    You can not protect your CSS.
  • Server Code
    It is always protected from end user.
  • Thanks,
    Imdadhusen
 
Share this answer
 
Comments
Uday P.Singh 21-Nov-11 7:35am    
Agree 5+
Sunasara Imdadhusen 21-Nov-11 7:38am    
If you have any idea about "How to prevent user to Save Page As.. option from File menu?" ?

Please do let me know! :)
Please refer following article.

This is best example. Also it compresses css and javascript files.

Automatically Minify, Combine, Compress, and Cache *.js and *.css Files in your ASP.NET Project[^]
 
Share this answer
 
Comments
Sunasara Imdadhusen 23-Nov-11 3:50am    
Nice link! my vote of 5
[no name] 23-Nov-11 5:06am    
Nice link. It improves performance of the system a lot.
it is easy to implement whenever user right click on a webpage this script get execcuted.
and protect our code.
to do add this script in asp.net page

JavaScript
<script type="text/javascript">
        function disableRightClick() {
            if (event.button == 2) {
                alert('For Security Reason Right Click is Disabled')
            }
        }
        document.onmousedown = disableRightClick
</script>


in body tag you will add this for call this script
HTML
<body  öncontextmenu="return false">

hope this is useful for you.
happy coding
from vikranth reddy
 
Share this answer
 
v2
Comments
Sunasara Imdadhusen 21-Nov-11 7:53am    
Good one!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900