Prevent Javascript from being downloaded

  • Thread starter Thread starter Ryu
  • Start date Start date
R

Ryu

Hi,

May I know how to prevent Javascript from being dlownloaded when the user
saves at "View Source"? I have added "js" at IIS's application
configuration's mapping and i have added the following at web.config:
But the javascript is still being downloaded. Please help

<httpHandlers>
<add verb="*" path="../ig_common.js"
type="System.Web.HttpForbiddenHandler"/>

</httpHandlers>
 
Well,

Javascript that has to be executed at the client side must be sent to the
client, and since Javascript is an interpreted language there is *NO* way of
preventing the user to download and see the Javascript code.

You could try to make it as difficult as possible, but there will be always
a way to see the code: the borwser should see it as well, no ?

The best option, in my opinion, is to obfuscate the Javascript code: see
http://www.syntropy.se for example.

Wim
 
Hi Ryu,

You can also copy the code in .js file to the ASPX file within the <script>
</script> tag.
and you can prevent the user from doing the View Source in the browser (of
course you need to write code for this ).

Check this thread which will help you achive disabling the view -> source
option.
http://www.experts-exchange.com/Web/Web_Languages/HTML/Q_20661699.html

This way you will be able to giveout the .js file to the user.

Hope this helps you.

Thanks
Raghavendra
 
Javascript that has to be executed at the client side must be sent to the
client, and since Javascript is an interpreted language there is *NO* way of
preventing the user to download and see the Javascript code.

I thought so too, until last week. A colleague developed a test page that
uses an ASP page for the (external) javascript source. I'm not sure how he
kept it out of the browser cache, but it certainly wasn't in there. I would
suspect it had something to do with the headers it sent with the script
document.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Back
Top