Javascript 弹出窗口未在Safari中保留宽度/高度尺寸

Javascript 弹出窗口未在Safari中保留宽度/高度尺寸,javascript,safari,popup,Javascript,Safari,Popup,我使用这个脚本打开一个特定大小的弹出窗口并将其居中。除Mac OS 10.9.5上的Safari 9.0.1版外,它可以按预期工作,在该版本中,窗口以全尺寸打开。 它适用于Mac上的所有其他浏览器 知道为什么指定的窗口大小在Safari中不起作用吗 function PopupCenter(url, title, w, h) { var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.l

我使用这个脚本打开一个特定大小的弹出窗口并将其居中。除Mac OS 10.9.5上的Safari 9.0.1版外,它可以按预期工作,在该版本中,窗口以全尺寸打开。 它适用于Mac上的所有其他浏览器

知道为什么指定的窗口大小在Safari中不起作用吗

function PopupCenter(url, title, w, h) {
  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, 'toolbar=no, location=no, directories=no, status=no, menubar=no,scrollbars=yes,resizable=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);

  // Puts focus on the newWindow
  if (window.focus) {
    newWindow.focus();
  }
}
用法:

<a href="#" onclick="PopupCenter('http://www.google.com','Window title','500','600'); return false;">Click</a>

尝试将这些用于此javascript支持所有浏览器的宽度/高度:

var width = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;

var heigth = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight; 
这可能是因为它使用body.clientHeight/body.clientWidth,但不是100%确定。

希望这有帮助

尝试将这些用于此javascript支持所有浏览器的宽度/高度:

var width = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;

var heigth = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight; 
这可能是因为它使用body.clientHeight/body.clientWidth,但不是100%确定。

希望这有帮助

经过大量调查,这个问题似乎只发生在这个特定的MacBook上。这不是一个通用问题,所以我暂时关闭这个topis。

经过大量调查,似乎这个问题只发生在这个特定的MacBook上。这不是一个通用问题,所以我现在就关闭这个topis。

啊,这是一个问题,不能进一步帮助你,因为我没有mac,safari在windows上不工作。啊,这是一个问题,不能进一步帮助你,因为我没有mac,safari在windows上不工作