北京漂流哪里最好:为什么我加了这段代码就不能滚屏了?

来源:百度文库 编辑:中科新闻网 时间:2024/05/05 14:45:32
为什么我加了第一行代码双击就不能滚屏了,去掉就可以了
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<script language="javascript">
var currentpos,timer;
function initialize()
{
timer=setInterval("scrollwindow()",10);
}
function sc(){
clearInterval(timer);
}
function scrollwindow()
{
currentpos=document.body.scrollTop;
window.scroll(0,++currentpos);
if (currentpos != document.body.scrollTop)
sc();
}
document.onmousedown=sc
document.ondblclick=initialize
</script>
</head>
<SCRIPT LANGUAGE="JavaScript">
<!--
for(i=1;i<50;i++)
{ //n=i;
if(i<10){n="0"+i;}else{n=i;}
document.write("<li style='CURSOR: hand'>这是第"+n+"行</li>");
}
//-->
</SCRIPT>
我的网站现在正在用标准来做,是不是采用了标准以后那些代码就不能用了?有什么原因吗?

DOCTYPE声明不合适
试试
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

因为第一行加入了W3C标准。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
把上面的换成<html>就可以了!