简体   繁体   中英

A help window with/without vertical scrollbar

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM