javascript - window.open 高度在 Google Chrome 中与其他浏览器不同

标签 javascript google-chrome popup window.open

我正在使用 javascript 的 window.open 在用户点击指定宽度和高度 (760x581) 时打开浏览器窗口,这在 Internet Explorer、Safari 和 Firefox 上工作正常,但谷歌浏览器给我带来了问题。在其他浏览器中,高度被正确用作内容的高度,但在 Google Chrome 中,它使实际浏览器窗口高 581 像素而不是内容。有办法解决这个问题吗?

<a href="http://domain.com/example.php" onclick="window.open('http://domain.com/example.php', '', 'width=760, height=581, top=15, left=15, toolbar=0, menubar=0, scrollbars=1, resizable=1, copyhistory=0, location=0, directories=0, status=1, titlebar=1, personalbar=0');return false">click here</a>

最佳答案

所以我把事情搞砸了,发现一些浏览器支持 window.open 的属性 innerHeight 并且以下内容在所有具有所需内容高度的浏览器中按预期工作在 775px 和 50px 仅添加到 Chrome:

window.open($(this).attr('href'), 'videoplayer',
   'width=1242, height=775, innerHeight=825, location=no, menubar=no, status=no, titlebar=no, scrollbars=no'
);

我在 Chrome 6.0.472.63、Firefox 3.6、3 和 2、IE 8 和 7 以及 Opera 10.62 中对此进行了测试。当我只使用 height 时,Chrome 大约 50px 太短并且有滚动条,但上面的所有浏览器都很好。将添加的 innerHeight 属性设置为比我希望的多 50px,它在 Chrome 和所有其他浏览器中都能正常工作。

更新:看起来这在 Safari 中造成了一个问题,即增加了 50 像素的高度。将研究解决该问题的方法。

关于javascript - window.open 高度在 Google Chrome 中与其他浏览器不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3462374/

相关文章:

javascript - 弹出窗口始终显示相同的数据

javascript - 观察表格提交

javascript - 最佳实践 - ASP.NET 合并所有 JavaScript 输出

JavaScript 'onclick' 在 Google Chrome 中无法运行

html - SVG foreignObject 中的 Div 在 Mac Chrome 中失去了位置

javascript - 有一个列表(其中项目没有 id)如何使 div 弹出窗口出现在鼠标悬停时?

javascript - jQuery IE9 : Unable to get value of the property 'val' : object is null or undefined

javascript - Backbone : Why are events syntax quite different between model and view?

javascript - 将 "new Number"分配给原型(prototype)字段在 Chrome 中打印为 {}

带有箭头的 Flutter 弹出窗口