带/不带垂直滚动条的帮助窗口


A help window with/without vertical scrollbar

我正在尝试在Web应用程序中实现帮助功能。按 F1 键,将显示一个弹出窗口,无论是否显示垂直滚动条。

$(document).keydown(function(event){
    var keycode = (event.keyCode ? event.keyCode : event.which);
    if(keycode == '112'){    //F1
        popup("help.php");    
    }
});

弹出功能应在屏幕中间打开一个新窗口。

function popup(page)
{
height = '220';
width = '440';
var str = "height=" + height + ",innerHeight=" + height;
str += ",width=" + width + ",innerWidth=" + width;
if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;
    var xc = (aw - width) / 2;
    var yc = (ah - height) / 2;
    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
};
str += ",scrollbars=1"; 
window.open(page,"name",str);
}  

弹出窗口显示正确,但没有滚动条!
帮助.php是这样的:

<?php
// for the time beeing, feed with html code. Later this script will open a
// contextual help by using header("location: help_fx.php")
?>
<div>
1<br>
2<br>
3<br>
4<br>
5<br>
6<br>
7<br>
8<br>
9<br>
10<br>
11<br>
12<br>
13<br>
14<br> 
</div>   

有什么想法吗?谢谢。

您是否尝试过应用 CSS 规则

<style>.myDiv{ overflow:scroll}</style> <div class="myDiv"> some content </div>

? 当内容超过指定的容器大小时,这将提供滚动条,并在内容适合时省略它们。