Prevent Javascript from being downloaded

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>
 
W

WL

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
 
R

Raghavendra T V

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
 
K

Kevin Spencer

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top