JavaScript download document with $window.open in Internet Explorer - javascript

Within my AngularJS application I want to download a (dynamically generated) document.
In my controller I have
$window.open(url, "_blank");
This works perfectly in Chrome and in Firefox. However the behavious in IE (version 11) is different -> I get the file also downloaded but IE redirects the user to the home state/screen (so the user needs to navigate one step backwards to the last state/screen where he actually triggered the download)!?
What could be the solution here?
Thx

Related

Should JavaScript/jQuery objects disappear when download hyperlink is clicked

We use Atalasoft's web image viewing SDK to display TIF images in a web page. We recently upgraded to their client-side, JavaScript/jQuery based component and discovered some odd behavior. After initializing the control, if a link is clicked to a resource that should be downloaded, the control(s) clear themselves out. The issue exists in Chrome and IE 11 that I have tested.
Since it is a paid SDK, the easiest way to test this is to go to their demo at:
http://www.atalasoft.com/demos/dotimagewebdemo/
Once the page finishes loading, open a developer console and paste in the following (simply adds a download link to a file on their site):
$("body").append($("<div style='position:absolute;right:5px;top:5px;'><a href='/Gallery/WebViewingDemo.zip'>DOWNLOAD</a></div>"))
Clicking the download link will wipe out their controls on the page.
Adding download to the anchor tag resolves the issue in Chrome, but not IE.
Adding target='_blank' resolves the issue in both, but creates an ugly blank window first (that in my experience does not always close).
I am setting headers server-side to tell the browser to download the file rather than displaying it.
I guess my questions are two-fold:
Is it normal for JavaScript/jQuery based objects to disappear/destroy/whatever when a link is clicked to download a file or is this a problem with their implementation?
and
What is the best solution for this (preferably without the blank page showing up)? We need to support mainly Chrome, FF, and IE (most popular desktop versions).
Thanks in advance!

IE11 Compatibility issue on windows

I have a html page where I have 3 framesets. One frameset contains an attachment. The application works fine in IE8. But when I click the button that opens the html page with the 3 framesets in IE11 the attachment is detached from the pane and is shown as an individual tab. I tried adding the tag in my html page in the tag. But it still isn't working. When I change the compatibility mode from developer tools(F12) in IE11, the application is working fine. By default the compatibility mode is set to F5. The user cannot always change the compatibility mode from internet explorer. So, I want the compatibility mode to be set to "Edge" by default to IE11. Any help is highly appreciated.

open IE browser by default

I created a web site where I would like to have 1 of the button of my menu navigation to open the internet explorer browser. Since the URL I am pointing for this specific button can only be view with IE and not with Chrome, Firefox etc... Which mean if someone is using Chrome for example and want to access this specific link by clicking on it it will open IE browser and see the content. This is feasible? thanks in advance
No, this is not feasible.
Opening in another browser is totally user side. You would have to alert the user that this page is best viewed in Internet Explorer and leave it up to them to download/open Internet Explorer to view it.

Opening a WMV file with window.open, in firefox; how can I prevent blank window from opening or close after file downloads?

When you download a file on CNET.com, a message will display on the page to wait a moment and the download will start; if it doesn't, click the link. That's very similar to the page with which I'm working.
The user clicks a link and this page appears with a similar message to CNETs. The only difference is the file is a WMV file and it automatically opens and plays. It works fine in IE. It's not working correctly in Firefox. In Firefox, if the user goes Tools->Options->Applications and selects "Use Windows Media Player" for Windows Media Video File, it plays in the external WMP. If the user uses the WMP plugin, however, the page opens up a blank window and then plays the video in the external WMP.
window.open("test.wmv");
Is there a way to prevent it from opening a window or how can I close the window after the wmv is downloaded and played?
Thank you very much.
Update
I found a link, here, that may be related to this issue. It states that the blank window is a bug with how Firefox handles the WMP plugin, with respect to ASX files. The only difference between the link and my question is one file is of type WMV and the other is of type ASX. The link is dated 2007 and the problem is reported on Firefox 1.5, but perhaps it still has merit. Maybe Mozilla has not addressed this bug, ever (FYI: I'm using Firefox 9.0.1).
I'm starting to think there is no direct solution. I can put a disclaimer, inform the user to turn off the WMP plugin in Firefox. Would a modal window or iFrame be helpful?

Problem triggering download in IE8

I'm working on a bit of code that is supposed to trigger a download from a pop-up window that was working in IE7 but broken in IE8 (also working in chrome and firefox). The situation is that the parent window is from a different domain then the download link and open's a pop-up to a url (say, http://someother.domain.com/downloadHelper.jsp) that generates and returns this bit of javascript:
downloadURL=http://someother.domain.com/downloadServlet?content=blarg.txt
snip...
window.opener.top.location.href = downloadURL;
snip...
Using fiddler/js debugging to see what the browser's doing step-by-step - in IE7 I see this
Main pop-up comes up and makes request for the downloadHelper.jsp
window.opener line causes request to downloadServlet
Main window comes up with IE's download dialog.
However, in IE8 I see this:
Main pop-up comes up and makes request for the downloadHelper.jsp
window.opener line opens a new pop-up with makes a request to downloadServlet
Both pop-up windows close with no IE download dialog
Any ideas on what's going on here?
Add X-UA-Compatible: IE=EmulateIE7 to your page or response headers to force IE8 and 9 to use the IE7 Document Mode (only if you are 100% sure your visitors will be using IE browsers).

Categories

Resources