By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,845 Members | 1,288 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,845 IT Pros & Developers. It's quick & easy.

Prevent file execution when opened in browser

P: 4

I have a requirement in which I have Prevent code from being executed when opened in browser. To put it in simple words, consider the following scenario
I have a file present in webserver.
if i tries to open this file from browser, instead of displaying the content, it should popup a dialog-box asking user to open/save/cancel.

Any help in this regard will be appreciated. Let me know if my requirement is not clear.

Oct 21 '08 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 15k+
P: 16,027
You can't do this with JavaScript. Keep the file out of the web root.
Oct 21 '08 #2

Expert 100+
P: 392
I properties file is not executable. It is just plain text, it can only be displayed.

If you want to force a save file dialog box you will need to change the response MIME type to an invalid value. Something like "application/unknown" or "app/download". That is not something you do with JavaScript. You would need to change the server configuration, or use server side code.
Oct 21 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.