3

Internet explorer has a security setting, which allows enable/disable file download. There is a button in our application which which opens the file (e.g. .xls) with window.open("fileurl"). Is it possible to detect in javascript that the download was blocked (and e.g. show some explanation)? Or more sophisticated is it somehow possible to detect it from request header?

Edit:
I have tried ajax, as suggested, to test download with no success. I suppose that saving or opening file is blocked not actual download.

var xhr = new XMLHttpRequest();
xhr.open("GET", docurl, false);
xhr.send(null);
var data = new VBArray(xhr.responseBody).toArray();//IE9 only

It succeeds and returns an array of the same length whether is the download disabled or not.
Getting and Sending Binary Files with XMLHttpRequest
how do I access XHR responseBody (for binary data) from Javascript in IE?

Edit 2:
My second attempt:

var wnd = window.open()
wnd.load=tst;
wnd.location.href= docurl

I tried to evalueat window in on load (tst) but I did not find difference with download prohibited or not.

Community
  • 1
  • 1
IvanH
  • 5,039
  • 14
  • 60
  • 81

2 Answers2

3

Heres a idea: have a ajax request to download a "test file" that is similar to the one blocked, with the same mime type and a real empty file of the type if possible (but small, maybe 2KB). Then if such download fail, ... you can also check how it fail (silently, with error message, ... ).. that will give you more information about how to solve that.

Tei
  • 1,400
  • 8
  • 6
  • I think you are out of luck, because now seems its blocked outside of the page context. "On the OS". Are these files bloqued wen the mime type is octect/stream? – Tei Apr 11 '12 at 08:49
  • I suppose that files which can be opened by browser (.txt, image, ...) are OK and others are blocked. I was said that even .pdf works, but I did not succeed to confirm it. I am not sure whether it is influenced by mime or extension, but it does not matter I just need to open or download it. – IvanH Apr 11 '12 at 09:03
0

There is now answer for about a month so I conclude that there is no solution.

IvanH
  • 5,039
  • 14
  • 60
  • 81