我正在尝试在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);
}
弹出窗口正确显示但没有滚动条!
help.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>
有什么想法吗?谢谢。
答案 0 :(得分:1)
您是否尝试过应用CSS规则
<style>.myDiv{ overflow:scroll}</style> <div class="myDiv"> some content </div>
?当内容超出指定的容器大小时,这将提供滚动条,并在内容适合时省略它们。