带有滚动条的JavaScript弹出窗口

时间:2013-05-29 05:51:09

标签: javascript scrollbar

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

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=yesscrollbars=autoscrollbars=1但滚动条仍然没有出现。我的代码有问题吗?我正在使用Firefox 21.0,我已经在IE 8中测试了它。这似乎是什么问题?

1 个答案:

答案 0 :(得分:15)

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