doujiyan0971 2013-09-10 13:36
浏览 23
已采纳

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

I am trying to implement a help function in a web application. By pressing F1, a pop-up window shall be displayed with, or not, a vertical scrollbar.

$(document).keydown(function(event){

    var keycode = (event.keyCode ? event.keyCode : event.which);

    if(keycode == '112'){    //F1
        popup("help.php");    
    }

});

The popup function should open a new window in the middle of the screen.

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

The popup window is correctly displayed but there is NO scrollbar !
The help.php is like this:

<?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>   

Any ideas ? Thank you.

  • 写回答

1条回答 默认 最新

  • dsjhejw3232 2013-09-10 13:43
    关注

    Have you tried applying the CSS rule

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

    ? That would provide scroll bars when the content exceeds the specified container size and omit them when the content fits.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog