I have this function:
var replyTo = null;
var windWidth = 730;
var windHeight = 550;
var windTop = parseInt((screen.availHeight - windHeight) / 3);
var windLeft = parseInt((screen.availWidth - windWidth) / 2);
function windowPreOpen() {
replyTo = window.open('', 'Connect With Twitter', 'width=' + windWidth + ', height=' + windHeight + ', left=' + windLeft + ', top=' + windTop + ', scrollbars, resizable');
window.focus();
};
function makeReplyTo() {
windowPreOpen();
var user_id = "3";
var data = $.ajax({
type: "POST",
url: "uspolitics_pulse/functions.php",
data: {
type: 'checkOauth',
user_id: user_id
},
success: function (data) {
if (data) {
replyTo = window.open(data, 'Connect With Twitter', 'width=' + windWidth + ', height=' + windHeight + ', left=' + windLeft + ', top=' + windTop + ', scrollbars, resizable');
replyTo.focus();
} else {
replyTo.close()
replyTo = $.prettyPhoto.open('');
}
}
});
}
It contains a little trick to avoid the popup blocker blocking my popup window. It opens an empty popup as first and then replace it with the right one.
The problem is I have to hide the first popup under the main window and then focus on the new one.
But when I try to use replyTo.focus(); the popup window remains hidden behind the main one, and looks like I cannot do anything to fix this issue.
Is there a way to re-focus on the popup window??
Please have a look to the code.
Thanks
Why not simply create one pop-up window; don't hide it; and update its location when the XHR returns? ie something like:
var replyTo = null;
var windWidth = 730;
var windHeight = 550;
var windTop = parseInt((screen.availHeight - windHeight) / 3);
var windLeft = parseInt((screen.availWidth - windWidth) / 2);
function windowPreOpen() {
replyTo = window.open('', 'Connect With Twitter', 'width=' + windWidth + ', height=' + windHeight + ', left=' + windLeft + ', top=' + windTop + ', scrollbars, resizable');
window.focus();
};
function makeReplyTo() {
windowPreOpen();
var user_id = "3";
var data = $.ajax({
type: "POST",
url: "uspolitics_pulse/functions.php",
data: {
type: 'checkOauth',
user_id: user_id
},
success: function (data) {
if (data) {
replyTo.location = data;
} else {
replyTo.close();
replyTo = $.prettyPhoto.open('');
}
}
});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.