When opening js script in browser downloads file






















I had something similar happening to me with a JSON, for me on the server side I was setting the header to self. Also know that in order for the file to still keep the.

Try link. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow.

Learn more. Instead of downloading, files are opening in browser Ask Question. Asked 3 years, 1 month ago. Active 2 years, 2 months ago. Viewed 14k times. MrtN 9 9 bronze badges. Amit Chauhan Amit Chauhan 1 1 gold badge 3 3 silver badges 13 13 bronze badges.

The download doesn't work with all browser. HTML5 added the download attribute for a elements which enables this. With html5, it is possible now. Set a "download" attr in element. Sarim Sarim 2, 2 2 gold badges 17 17 silver badges 20 20 bronze badges. Add this header to your file. Thanks a lot for your quick reply.

I should also note that I don't have control over the http server that serves the. This happens. No worries, just thought I'd let you know.

Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. By creating Virtual Directory on your IIS that mapped to any physical drive you should be able to open files. The virtual directory will have some http: address. So instead of window. The xmlhttp request method is not valid for the files on local disk because the browser security does not allow us to do so.

This is tested on chrome,however care should be taken that all browser windows should be closed and the code should be run from the browser opened via this shortcut. You can't. New browsers like Firefox, Safari etc. It will only work on old browsers. Javascript cannot typically access local files in new browsers but the XMLHttpRequest object can be used to read files.

So it is actually Ajax and not Javascript which is reading the file. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to open a local disk file with JavaScript? Ask Question. Asked 11 years, 3 months ago. Active today. Viewed k times. I tried to open file with window. Joval Joval 1, 2 2 gold badges 12 12 silver badges 3 3 bronze badges.

Add a comment. Active Oldest Votes. Bachask8 Bachask8 1 1 gold badge 7 7 silver badges 18 18 bronze badges. Andrey M. MapPath string. LongLength; oPdfResult. AddHeader "content-length", Model. Sign up or log in Sign up using Google.

Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog.



0コメント

  • 1000 / 1000