js scrollTop问题
<scripttype="text/javascript">vartimerfunctionscrolltop(){document.getElementById('sc...
<script type="text/javascript">
var timer
function scrolltop()
{
document.getElementById('scrollmenu').style.top=document.documentElement.scrollTop+"px"+document.body.scrollTop+"px"
timer=setTimeout("scrolltop()",1)
}
function stoptimer()
{
clearTimeout(timer)
}
</script>
这段js在ie、火狐和谷歌里面都没有效果,请问一下是哪里错了吗?多谢
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="description" content="" />
<title>DHTML</title>
<link href="include/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src=""></script>
<!-- javascript 多得话会影响html内容导入 -->
<script type="text/javascript" defer src=""></script>
<!-- defer 不会影响到页面构造,也就是说脚本会延迟等到页面解析完后在运行 defer浏览器支持不好 -->
</head>
<body onload="scrolltop()" onunload="stoptimer()">
<div class="box">
<!-- javascript -->
<script type="text/javascript">
var timer
function scrolltop(){
document.getElementById("scrollmenu").style.top=document.documentElement.scrollTop+document.body.scrollTop;
timer=setTimeout("scrolltop()",1)
}
function stoptimer()
{
clearTimeout(timer)
}
</script>
<!-- html -->
去掉这个<!doctype html>就是好的,再不去掉的情况下能有解决方案吗 展开
var timer
function scrolltop()
{
document.getElementById('scrollmenu').style.top=document.documentElement.scrollTop+"px"+document.body.scrollTop+"px"
timer=setTimeout("scrolltop()",1)
}
function stoptimer()
{
clearTimeout(timer)
}
</script>
这段js在ie、火狐和谷歌里面都没有效果,请问一下是哪里错了吗?多谢
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="description" content="" />
<title>DHTML</title>
<link href="include/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src=""></script>
<!-- javascript 多得话会影响html内容导入 -->
<script type="text/javascript" defer src=""></script>
<!-- defer 不会影响到页面构造,也就是说脚本会延迟等到页面解析完后在运行 defer浏览器支持不好 -->
</head>
<body onload="scrolltop()" onunload="stoptimer()">
<div class="box">
<!-- javascript -->
<script type="text/javascript">
var timer
function scrolltop(){
document.getElementById("scrollmenu").style.top=document.documentElement.scrollTop+document.body.scrollTop;
timer=setTimeout("scrolltop()",1)
}
function stoptimer()
{
clearTimeout(timer)
}
</script>
<!-- html -->
去掉这个<!doctype html>就是好的,再不去掉的情况下能有解决方案吗 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询