1
Я имею следующий JavaScript, которые открывают окна Дочернее окно с размерами и выравнивают его Int ситемы центр экранаTypeError: не определено не является объектом (оценка «newWindow.focus»)
function PopupCenter(url, title, w, h) {
// Fixes dual-screen position Most browsers Firefox
var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;
var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
var left = ((width/2) - (w/2)) + dualScreenLeft;
var top = ((height/2) - (h/2)) + dualScreenTop;
var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
// Puts focus on the newWindow
if (window.focus) {
newWindow.focus();
}
var timer = setInterval(checkChild, 500);
function checkChild() {
if (newWindow.closed) {
var message = 'You have aborted the transaction by closing the window !';
var status = 'closed';
paymentResponseDisplay(message,status)
clearInterval(timer);
}
}
window.onbeforeunload = function() {
if(!newWindow.closed){
return "Do you really want to abort this transaction?";
}
}
}
Но в сафари я получаю
TypeError: undefined is not an object (evaluating 'newWindow.focus')
Я не могу найти исправление для этого. Может ли кто-нибудь помочь?
Я не думаю, что я могу, но вы проверяете NewWindow вар через консоль? Вы проверили с помощью простого окна с минимальными параметрами? Посмотрите, если это имеет значение. – yezzz
попробовал все тот же – Ajeesh
, он может фактически не работать из-за ограничений браузера: https://developer.mozilla.org/en-US/docs/Web/API/Window/focus – yezzz