2

我在 Internet Explorer 中看到“无效参数”,window.open 使用 javascript。我将如何解决它?

我在“var newwindow = window.open (url, 'Popup Demo', 'toolbar=no, location=no, directory=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);"。

这是我的代码:

<script type="text/javascript" language="javascript">
<!--

function popitup(url) {

    var w = 500;
    var h = 500;

    var left = (screen.width/2)-(w/2);
    var top = (screen.height/2)-(h/2);

    var newwindow = window.open (url, 'Popup Demo', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);

    if (window.focus) {
        newwindow.focus();
    }
    return false;
}

// -->
</script>
4

3 回答 3

6

IE 中的窗口名称可能没有空格。更改'Popup Demo''PopupDemo'

于 2012-11-19T15:14:15.830 回答
1

According to https://developer.mozilla.org/en-US/docs/DOM/window.open, the second parameter, strWindowName, should not have any spaces in it. Since yours does, that might be the problem.

于 2012-11-19T15:16:56.023 回答
0

我发现了另一种情况,即 IE 和 Edge 在与子窗口交互期间显示“无效参数”错误。它发生在尝试将在父窗口文档中创建的元素插入到子窗口文档时。所有其他浏览器都可以正常工作。

于 2019-02-06T14:08:30.550 回答