admin管理员组文章数量:1312662
I run an e-merce website, and I need to get this popup working when a client submits an order. Ideally, the popop would appear when the order success page loads, but popup blockers will stop this.
Instead, I generate the popup when the use clicks the "confirm order" button, but this obscures the 3DSecure page that the checkout redirects to before the order finishes.
To counteract this, I create the popup when the user clicks "confirm order", but instantly refocus the main window; a pop-under if you will. My plan is to refocus this new window from the order success page.
The issue is that I cannot find a way to get the object for an existing popup so I can run the focus on it. if I create the window using window.open(url,windowName,options)
, is there a way I can reference that from another page? Something along the lines of window.load(windowName)
would be ideal.
I run an e-merce website, and I need to get this popup working when a client submits an order. Ideally, the popop would appear when the order success page loads, but popup blockers will stop this.
Instead, I generate the popup when the use clicks the "confirm order" button, but this obscures the 3DSecure page that the checkout redirects to before the order finishes.
To counteract this, I create the popup when the user clicks "confirm order", but instantly refocus the main window; a pop-under if you will. My plan is to refocus this new window from the order success page.
The issue is that I cannot find a way to get the object for an existing popup so I can run the focus on it. if I create the window using window.open(url,windowName,options)
, is there a way I can reference that from another page? Something along the lines of window.load(windowName)
would be ideal.
2 Answers
Reset to default 3The signature of window.open is like this.
var windowObjectReference = window.open(strUrl, strWindowName[, strWindowFeatures]);
MDN notes that,
If a window with the name strWindowName already exists, then strUrl is loaded into the existing window. In this case the return value of the method is the existing window and strWindowFeatures is ignored. Providing an empty string for strUrl is a way to get a reference to an open window by its name without changing the window's location.
So this should work for you.
window.open('', 'windowName', '');
According to MDN whenever a window is opened a reference to it is created,
var windowObjectReference = window.open("http://www.google.", "popup", "width=500,height=500");
You could always load it using that reference like
if(windowObjectReference != null || !windowObjectReference.closed) {
windowObjectReference .focus();
}
This is tricky but this works on Chrome. First, open the window:
window.open('/test', 'testw', '');
Another link (even on another page), opens a 'page' in that same window by passing the same window name. The URL is JavaScript (so it's rather a hack):
window.open('javascript:void window.focus()', 'testw', '');
http://jsfiddle/pimvdb/KeHtp/
本文标签: javascriptSelect and focus an already existing windowStack Overflow
版权声明:本文标题:javascript - Select and focus an already existing window - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741914087a2404619.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论