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).
Related
In a web application, I have an optional popup window into which logging content is being loaded. This window is opened via Javascript using window.open().
The users typically have multiple tabs of the application open and my intention is to always reuse the same popup window (if currently open), no matter from which tab they trigger the popup. To do so, I use code similar to this to open the popup:
<script>
function myFunction() {
var myWindow = window.open("popup.html", "my_popup", "width=600,height=400,status,resizable");
}
</script>
This works fine in Firefox and IE - only a single popup window is ever opened and all content that I want to log is being loaded into that window.
Chrome and Safari however, use different popup windows depending on the tab from which the popup is launched.
I assumed that the second parameter of window.open() specifies a target name from a global namespace, which seems to be the case for most browsers. But Chrome and Safari behave as if there were tab-specific namespaces for these target names, i.e. "my_popup" referenced from tab 1 refers to a different target than "my_popup" from tab 2. (to make things more complicated, tabs that have been "duplicated" seem to share the same namespace, i.e. they do reuse the same popup window, but tabs created otherwise don't.)
Is there a way to circumvent this behavior of Chrome and Safari and access the same popup window from all tabs that the user may have open?
Or do I have to assume that this is browser-specific behavior for which there seems to be no workaround?
I have tested this with various browsers:
IE 11.0.9600.18204
All tabs with content from the same domain open/reload a single shared popup window (i.e the target namespace seems to be local per domain).
All tabs with content from file:// URLs reuse the same popup window as tabs with content from http:// URLs that point to the local intranet.
Firefox 46.0.1
All tabs with content from the same domain open/reload a single shared popup window (i.e the target namespace seems to be local per domain).
All tabs with content from file:// URLs use their own single shared popup window (i.e. file:// URLs seem to have their own target namespace).
Edge 20.10240.16384.0
The behavior is inconsistent: in most of my tests, Edge behaved like Firefox, but occasionally like Chrome as well.
I don't have a problem in ignoring Edge for the time being.
Chrome 50.0.2661.94
Each tab opens or reloads its own popup window (i.e the target namespace seems to be local per tab)
Safari 9.1
Each tab opens or reloads its own popup window (i.e the target namespace seems to be local per tab)
By the way, in all of these browsers the behavior does not depend on whether or not the popup window was launched due to user interaction: the behavior is identical between cases where the popup is launched via body onload() and cases where it is loaded via button onclick().
[here's additional background information that I assume not to be relevant to the problem, but who knows... ;-)
Actually, our application does not directly open the popup windows, instead we're using log4javascript which opens a logging window (or in case of Chrome: multiple logging windows). I'm willing to extend the log4javascript code to deal with this and send a patch to the maintainer, but in order to do so I need to solve the basic problem described above]
When i open a new window using window.open javascript, chrome opens with about:blank, but firefox opens with jsfiddle back url and if you right click on the page, you can still see the page loading. You will not see the refresh icon, instead a stop icon is appearing.
I need to open the new window with about:blank.
Here is the jsFIDDLE
Tested with Chrome 45.0
Tested with Firefox 41.1
<button id="helper">Click here for help</button>
What you are experiencing is a new Firefox behavior that passed in version 40 or 41 (sorry I did not find the reference).
Expect it to become part of google's behavior soon too, you can see people requesting it already(Chrome issue)
Unfortunately there is not much that can be done for now as it is brand new people have not found workaround or even if it is a good idea to fight against the browser... My suggestion is to not use about:blank at all and use a blank html page from your domain, that would make things easier on the users.
Instead of about:blank take #:
$("#helper").click(function(){
windowURL = window.open("#","Looking ....
EDIT
in order to prevent the browser from showing an "infinite loading", close the document:
...
openedDocument.open();
openedDocument.write(myHTML)
openedDocument.close()
I'm using the following code to open a new tab on click of a PDF download.
The problem is the new tab becomes the main tab often before the PDF loads.
How can I make the view stay on the current window (PDF) and open the new tab but not switch to it?
Note: In Chrome and Opera they understand the HTML5 download tag so the PDF simply downloads and the current window redirects - All good! So this is only a problem on IE & Firefox.
<h2 style="text-align: center;"><a href="http://cdn2.hubspot.net/hub/155045/file-847580737-pdf/Stepping_into_a_new_age_of_marketing_with_CRM_FINAL_APPROVED.pdf" onclick="casestudiesopen()" download><strong>Click here to download your eBook</strong></a></h2>
<script>
function casestudiesopen() {
window.open("http://www.workbooks.com/case-studies");
}
</script>
Well, I'll advise you to read this Stackoverflow answer, which is, in a way, quite similar to yours (the purpose anyway) :
Javascript disable switches current tab functionality in browser
JS/JQuery is indeed very powerful but also have its limits. Imagine a web page always requesting and keeping focus once you've opened it. I think you would be really annoyed, among other things.
That's why browsers prevent those kind of actions. Common browsers at least. Meaning, there's no way to prevent a browser like Firefox, Chrome, IE & Co. to focus a table since it depend of user's parameters.
You'll have to find a way to workaround your problem. I can propose this answer since it seems to have worked for the other guy.
I am using Google Chrome Frame (GCF) with IE9 and when I open a javascript dialog it opens in a tab instead of a dialog.
My IE setting for 'Tabbed Browser Settings' -> 'When a pop-up is encountered:' -> 'Let Internet Explorer decide how pop-ups should open'
I use this javascript to open a window:
window.open("http://google.com/", "_blank",
"location=0,status=no,toolbar=no,menubar=no,width=800,height=600,scrollbars=no,resizable=no");
If I change the IE setting to 'Always open pop-ups in a new window' it works. The problem lies in that I need to change that setting on every IE9 computer in the company and the computer administrators are hesitant to do this.
According to Microsoft documentation if you specify a width/height it will open in a dialog but this is not the case when using GCF.
Is there anything I can do (other than changing the setting) that will force the dialog to open in a new window instead of a tab?
Also IE is crafty it tells you it changes the setting but sometimes it actually doesn't so when testing close out of the browser all the way after changing the setting (I got all excited once after it 'worked' but it was actually the setting not updating in IE).
You have to use the rel="noreferrer" in a standard link (no window.open).
I went through reams of documentation trying to figure this out.
Fortunately ChromeFrame isn't needed as much since IE11 seems to support most things (although IE11 has a horrible memory leak).
[a href="http://www.google.com" rel="noreferrer" target="_blank"]Rel No Referrer Is the Key[/a]
What are situation when you want to use window.showModalDialog function? It seams that you can do exactly the same with window.open function and few parameters that remove some of the chrome (navigation, addressbar, etc...)
When would you want to use window.showModalDialog and window.open?
It has been a few years since this question was originally asked and things have changed a bit since then. window.showModalDialog is now officially standardized as part of HTML5 and is supported in IE, Firefox 3+, Chrome (albeit buggy), and Safari 5.1+.
Unfortunately window.showModalDialog is still plagued by a number of issues.
Modal dialogs are blocked as popups by default in Firefox, Chrome, and Safari.
The modal dialogs in Chrome are buggy and aren't truly modal - see http://code.google.com/p/chromium/issues/detail?id=16045 & http://code.google.com/p/chromium/issues/detail?id=42939.
All browsers except Chrome block the user from interacting with the entire window (favorites, browser controls, other tabs, etc...) when a modal dialog is up.
They're a pain to debug because they halt JavaScript execution in the parent window while waiting for the modal dialog to complete.
No mobile browsers support window.showModalDialog.
Therefore it's still not a good idea to use window.showModalDialog. If you need the window opened to be modal (i.e. the user cannot interact with the rest of the page until they deal with the dialog) I would suggest using jQuery UI's dialog plugin.
window.open will work for non modal windows but I would stick with jQuery UI's dialog because opening new windows tends to annoy users.
If you're interested I write about this in more detail on my blog - http://tjvantoll.com/2012/05/02/showmodaldialog-what-it-is-and-why-you-should-never-use-it/.
Modal dialogs are dialogs that once opened by the parent, do not allow you to focus on the parent until the dialog is closed.
One could use a modal dialog for a login form, edit form, etc where you want to have a popup for user interaction but not allow the user to return to the window that opened the popup.
As a side note, I believe only Internet Explorer implementes window.showModalDialog, so that kind of limits your usage of it.
showModalDialog() is currently being standardized as part of HTML5. The third argument (for additional options) is not present in the HTML5 version, and is (safely) ignored by Safari and Chrome.
http://dev.w3.org/html5/spec//user-prompts.html#dialogs-implemented-using-separate-documents
Note that there's a bug in Chrome 2 which prevents showModalDialog() from loading properly. The popup window appears, but the content never loads.
One more reason to avoid using showModalDialog().
showModalDialog()works well in Internet Explorer, Firefox (3 and above)
Works in Chrome but popup is not model (you can go to parent window)
Note that while you can show modal from any popup window, you cannot use window.open from a model dialog in some browsers (IE, Safari).