Prevent file execution when opened in browser

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ajmerasunny
    New Member
    • Mar 2008
    • 4

    Prevent file execution when opened in browser

    Hi,

    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 locale.properti es 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.


    Thanks
    sunny
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    You can't do this with JavaScript. Keep the file out of the web root.

    Comment

    • pronerd
      Recognized Expert Contributor
      • Nov 2006
      • 392

      #3
      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 "applicatio n/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.

      Comment

      Working...