带有滚动条的JavaScript弹出窗口 [英] JavaScript popup window with scrollbars

查看:470
本文介绍了带有滚动条的JavaScript弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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?

推荐答案

As在 window.open 的规范中看到,您的参数是错误的。
试试这个:

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

这是 jsFiddle

这篇关于带有滚动条的JavaScript弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆