IE 9 doesn't update windows with window.open but opens a new window
I have the following line of code that is called by jQuery when a link is clicked:
alipayTransactionModalTrigger.click(function(e) {
e.preventDefault();
$.ajax({
url: "doSomething",
data: "p_locale=en-US",
success: function(dataOut){
if (dataOut == "hold") {
...do something...
} else {
//open a modal over parent window
alipayTransactionModal.dialog("open");
//also open new tab/window
var Payment = window.open("http://www.alipay.com", "Payment");
Payment;
Payment.focus();
}
}
});
return false;
});
The ajax call is just checking some values ββin the main. The challenge to success is going the way it should, that's not a problem. By using the frame name, I'm trying to get a newly opened window / tab to refresh when the link is clicked more than once. This works in IE 8, Chrome and Firefox - the user can click the link as many times as they want and it will only open one window - subsequent clicks will simply reload that window.
However, this does not happen with IE 9 - IE 9 opens a new window / tab every time. Any way to force this behavior in IE 9? Or even just explaining why this is happening in IE 9 would be great - is it a user level setting? From what I can tell, IE9 just doesn't know what I'm pointing at when I use the frame name in window.open()
.
One more thing I should mention: .focus()
doesn't always focus the window on clicks of the second / third / etc. (seems to depend on browser and browser settings) - but I already asked this question here Just enable it here if relevant.
thank
opening a window with a .open window from an ajax callback is doomed to be blocked by the popup blocker. i believe that if you disable it it will work as expected.
Check out this answer right here. Window.open is locked You need the correct context for your window.
I don't have IE9 to test, but maybe this helps
var openLink = (function() {
var _popups = {};
return function(link, name) {
if (_popups.hasOwnProperty(name) === false) {
_popups[name] = window.open();
}
_popups[name].location.href = link;
_popups[name].focus();
};
}());
Example