leechun
05-14-2003, 07:21 PM
hello people:
I am fairly new to JavaScript and have been experimenting with it on my own. I have got this question I wonder if anyone can tell me why.
I have been trying to resize the background image to the size of the document using "document.body.clientWidth" and "document.body.clientHeight". it kind of works. However, the scroll bars always seems to appear, which I think they should not as the size of the image is the exact size of the document. Making sense? Anyway, the code goes like this.
Thanks for your time the help :)
<html>
<head>
<script type = "javascript">
function get_win_size()
{
var win_width = document.body.clientWidth;
var win_height = document.body.clientHeight;
bg.width = win_width;
bg.height = win_height ;
timer=setTimeout("get_win_size()",100);
}
function stoptimer()
{
clearTimeout(timer)
}
</script>
</head>
<body onload = "get_win_size()" onunload = "stoptimer()">
<div style="position:absolute;top:0px;left:0px">
<img id = "bg" src = "images/some_picture.gif" >
</div>
</body>
</html>
I am fairly new to JavaScript and have been experimenting with it on my own. I have got this question I wonder if anyone can tell me why.
I have been trying to resize the background image to the size of the document using "document.body.clientWidth" and "document.body.clientHeight". it kind of works. However, the scroll bars always seems to appear, which I think they should not as the size of the image is the exact size of the document. Making sense? Anyway, the code goes like this.
Thanks for your time the help :)
<html>
<head>
<script type = "javascript">
function get_win_size()
{
var win_width = document.body.clientWidth;
var win_height = document.body.clientHeight;
bg.width = win_width;
bg.height = win_height ;
timer=setTimeout("get_win_size()",100);
}
function stoptimer()
{
clearTimeout(timer)
}
</script>
</head>
<body onload = "get_win_size()" onunload = "stoptimer()">
<div style="position:absolute;top:0px;left:0px">
<img id = "bg" src = "images/some_picture.gif" >
</div>
</body>
</html>