4

我有一个在中心弹出窗口的功能,我希望它有一个垂直滚动条。

function popUpCal()
{
    var url = "calendar_flight_maint.php";
    var width = 700;
    var height = 600;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
window.open(url, "subWind", windowFeatures, "POS", "toolbar=no", "scrollbars=1");
}

我试过scrollbars=yes, scrollbars=autoscrollbars=1但滚动条仍然没有出现。我的代码有问题吗?我正在使用 Firefox 21.0,并且已经在 IE 8 中对其进行了测试。这似乎是什么问题?

4

1 回答 1

16

从window.open的规范中可以看出,您的参数是错误的。尝试这个:

function popUpCal()
{
    var url = "calendar_flight_maint.php";
    var width = 700;
    var height = 600;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var windowFeatures = "width=" + width + ",height=" + height +   
        ",status,resizable,left=" + left + ",top=" + top + 
        "screenX=" + left + ",screenY=" + top + ",scrollbars=yes";

    window.open(url, "subWind", windowFeatures, "POS");
}

这是一个jsFiddle

于 2013-05-29T06:07:16.460 回答