Javascript 带有窗口的弹出窗口的大小。打开不一致,并调整内部宽度/高度

Javascript 带有窗口的弹出窗口的大小。打开不一致,并调整内部宽度/高度,javascript,html,css,Javascript,Html,Css,我想打开一个弹出窗口与我提供的确切大小 我正在使用 window.open(url,'newwindow','resizable=yes,menubar=no,status=no,toolbar=no,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top) 在我的例子中,我使用了: width='400px' height='300px' top=left='300p

我想打开一个弹出窗口与我提供的确切大小

我正在使用

window.open(url,'newwindow','resizable=yes,menubar=no,status=no,toolbar=no,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top)
在我的例子中,我使用了:

width='400px'
height='300px'
top=left='300px'
在Chrome中,它工作正常,我得到了一个内部尺寸为400x300px的新窗口

在IE(v11)中,我得到一个带有404x304px的窗口

在FF(v31)中,我得到一个398x299px的窗口

但我需要它完全像Chrome中的400x300px,否则我的窗口调整事件侦听器会遇到大问题

我快发疯了,我是不是做错了什么?是否有人知道如何解决这个问题,或者这是一个已知的问题

我只是在为这个项目使用普通的HTML/JavaScript

编辑:

我只是想出了一个小办法。 我只是在弹出式html的HEAD标记中添加了以下内容:

<script>
    window.innerResizeTo = function(targetWidth, targetHeight) {
        if(window.innerWidth || window.innerHeight) {
            var innerWidth = window.innerWidth,
            innerHeight = window.innerHeight;
        } else {
            var innerWidth = window.document.documentElement.clientWidth || window.document.body.clientWidth,
            innerHeight = window.document.documentElement.clientHeight || window.document.body.clientHeight;
        }

        if (innerWidth != targetWidth && innerHeight != targetHeight) {
            if(window.outerWidth || window.outerHeight) {
                var outerWidth = window.outerWidth,
                outerHeight = window.outerHeight,
                fixedwidth = targetWidth + outerWidth - innerWidth,
                fixedheight = targetHeight + outerHeight - innerHeight;
            } else {
                window.resizeTo(300,300);

                var outerWidth = window.document.documentElement.clientWidth || window.document.body.clientWidth,
                outerHeight = window.document.documentElement.clientHeight || window.document.body.clientHeight,
                fixedwidth = targetWidth + 300 - outerWidth,
                fixedheight = targetHeight + 300 - outerHeight;
            }

            window.resizeTo(fixedwidth,fixedheight);
        }
    }

    window.innerResizeTo(400,300);

</script>

window.innerResizeTo=函数(targetWidth,targetLight){
if(window.innerWidth | | window.innerHeight){
var innerWidth=window.innerWidth,
innerHeight=window.innerHeight;
}否则{
var innerWidth=window.document.documentElement.clientWidth | | window.document.body.clientWidth,
innerHeight=window.document.documentElement.clientHeight | | window.document.body.clientHeight;
}
if(innerWidth!=targetWidth&&innerHeight!=targetHeight){
if(window.outerWidth | | window.outerwight){
var outerWidth=window.outerWidth,
outerHeight=window.outerHeight,
fixedwidth=targetWidth+外层宽度-内层宽度,
固定高度=目标高度+外部高度-内部高度;
}否则{
窗口。resizeTo(300300);
var outerWidth=window.document.documentElement.clientWidth | | window.document.body.clientWidth,
outerHeight=window.document.documentElement.clientHeight | | window.document.body.clientHeight,
固定宽度=目标宽度+300-外径,
固定高度=目标光+300-外光;
}
窗口大小(固定宽度、固定高度);
}
}
窗口。innerResizeTo(400300);
它非常难看,但可以工作(在win7 x64上,使用IE v11 FF v31和Chrome v36)

我希望这能帮助其他人解决同样或类似的问题。
顺便说一句,非常欢迎提出改进意见。

只是想知道。。是否尝试添加“px”以指定大小?或者浏览器假定您正在传递像素?是的,刚刚编辑了问题。px已经在我的VAR中,我只是忘了在这里添加;)我猜代码没有问题,可能是ie中排除了浏览器装饰,Firefox中采用了浏览器装饰。为了测试,我在弹出窗口中打开了一个html,首先是两个div,黑色400x300,带有1px填充(边框框,因此400x300中包含1px填充),内部是灰色的。在IE中,我在底部和右侧有一个白色的4px边框,在FF中,黑色边框(第一部分)在底部和右侧缺失。