最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

JavaScript popup window with scrollbars - Stack Overflow

programmeradmin4浏览0评论

I have a function that pops up window in the center and I want it to have a vertical 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");
}

I have tried scrollbars=yes, scrollbars=auto, scrollbars=1 but the scrollbars still aren't appearing. Is there something wrong with my code? I'm using Firefox 21.0 and I've already tested it in IE 8. What seems to be the problem?

I have a function that pops up window in the center and I want it to have a vertical 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");
}

I have tried scrollbars=yes, scrollbars=auto, scrollbars=1 but the scrollbars still aren't appearing. Is there something wrong with my code? I'm using Firefox 21.0 and I've already tested it in IE 8. What seems to be the problem?

Share Improve this question edited May 29, 2013 at 6:01 xjshiya asked May 29, 2013 at 5:51 xjshiyaxjshiya 9257 gold badges16 silver badges45 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 16

As seen in the specs for window.open, your parameters are wrong. Try this:

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");
}

Here is a jsFiddle

发布评论

评论列表(0)

  1. 暂无评论