javascript - window.open 无效参数错误

标签 javascript

因此,每当我尝试运行此脚本时,我都会收到无效参数错误。错误发生在 window.open(url, name, features); 不幸的是我不知道如何解决这个问题。有什么想法吗?

Common-Utilities.js(问题出在哪里 - 第 4 行)

var wm = new function WindowManager() {
    this.open = function (url, features) {
        var name = this.getName(url);
        var handle = window.open(url, name, features);
        handle.focus();
        return handle;
    };
    this.getName = function (url) {
        name = getAbsolutePath(url);
        return name.replace(/[:.\+\/\?\&\=\#\%\-]/g, "_").toLowerCase();
    };
    var getAbsolutePath = function (url) {
        var a = document.createElement('a');
        a.href = url;
        return a.href;
    }
};

openPopUp.js

function openPopup(url, width, height) 
{   
    if (width == -1) width = 710;
    if (height == -1) height = 500;

    var left = (window.screen.availWidth - width) / 2;
    var top = (window.screen.availHeight - height) / 2;

    if (window.screenLeft>window.screen.availWidth)
    {
        left = left + window.screen.availWidth;
    }

    // open url in new browser window
    var handle = wm.open(url, 'location=0, menubar=0, resizable=1, scrollbars=1, status=0, toolbar=0, width=' + width + 'px, height=' + height + 'px, top=' + top + 'px , left=' + left + 'px');

    //tile the windows so user can tell a new window has been opened
    if (document.body.clientHeight==height)
    {   
        var metricTop=10;
        var metricLeft=10;
        var thisTop=self.screenTop+metricTop;
        var thisLeft=self.screenLeft+metricLeft;
        if (thisTop<0) thisTop=0;
        if (thisLeft<0) thisLeft=0;
        handle.moveTo(thisLeft, thisTop);
    }

}

function popOutOrIn(url, title, width, height, popOut) {
    if (width == -1) width = 710;
    if (height == -1) height = 500;

    if (popOut === 'True') {
        openPopup(url, width, height)
    }
    else {
        window.top.popUpRadWindow(url, title, width, height);
    }
}

最佳答案

我们有代码...这是修复方法:

 var handle = wm.open(url,'I want a name!', 'location=0, menubar=0, resizable=1, scrollbars=1, status=0, toolbar=0, width=' + width + 'px, height=' + height + 'px, top=' + top + 'px , left=' + left + 'px');

关于javascript - window.open 无效参数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6255909/

相关文章:

javascript - 将表单上的 javascript 验证更改为 onblur 或 onchange 而不是提交

javascript - 将 props 传递给 react-router v4 中的路由器组件

javascript - 当所有 HTML/CSS 和 Javascript 代码都被触发时,如何将 Javascript 代码触发到最后?

javascript - Javascript 数字格式正则表达式不起作用

javascript - 在 iPad 网络应用程序中禁用垂直弹跳效果

javascript - HTML/Javascript - setTimeout 问题

javascript - 从 Javascript 发布到 ASP.NET 中的 Controller 的 DateTime 结果为 null (01/01/0001)

javascript - 如何在 Javascript 中进入 n 维对象数组?

javascript - nightwatch自定义命令的执行模型是什么,如何等待它们?

javascript - 按钮不应该调用 php 函数