想做个弹来弹去的窗口漂浮但是总是不可以获得正确的高宽用过
window.document.body.offsetWidth/offsetHeight
window.innerHeight/innerWidth 我的IE好像不支持
window.screen.* 高宽是屏幕的吧?想获得当前窗口的怎么弄?
烦恼了
window.document.body.offsetWidth/offsetHeight
window.innerHeight/innerWidth 我的IE好像不支持
window.screen.* 高宽是屏幕的吧?想获得当前窗口的怎么弄?
烦恼了
document.body.clientWidthvar win = window.open("about:blank", "_blank", "width=200,height=200");
alert(win.document.body.clientHeight);
width可以就是说和这句一样
document.body.offsetWidth/offsetHeight难道是我写的层有什么有错吗?测试代码:
<html>
<head>
<script>
var gox=1;
var goy=1;
function move()
{
var w=document.body.clientHeight;
var h=document.body.clientWidth;
alert(w+"\n"+h);
}</script><title>漂浮</title>
</head><body onload=move() >
<div id="layer1"><img src="img/piaofu.jpg" width="150" height="100" /></div>
</body>
</html>
为什么不能获得?<html>
<head>
<script>
var gox=1;
var goy=1;
function move()
{
var w=document.body.offsetWidth;
var h=document.body.offsetHeight;
alert(w+"\n"+h);
var speedx=20;
var speedy=Math.tan(Math.PI/4)*speedx;
var x=document.getElementById("Layer1").style.left;
var y=document.getElementById("Layer1").style.top;
if(parseInt(x)+150>w||parseInt(x)<0)
gox=-gox;
if(parseInt(y)+150>w||parseInt(y)<0)
goy=-goy;
document.getElementById("Layer1").style.left=parseInt(x)+speedx*gox;
document.getElementById("layer1").style.top=parseInt(y)+speedy*goy;
setTimeout("move()",800);
}</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>漂浮</title>
</head><body onload=move() >
<div id="layer1" style="position:absolute; left:0px; top:0px; width:150px; height:100px; x;z-index:10;"><img src="img/piaofu.jpg" width="150" height="100" />
<h2>漂浮广告</h2></div>
</body>
</html>
document.body.clientWidth
在xhtml1-transitional里得不到呀,在那里document.body.clientWidth是和document.body.offsetWidth一样的!!!!!