为什么我在html里面是可以上下滚动的,加到asp.net页面中就不会动了?我把代码贴出来了,大家帮我看下,比较急~~~~~
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!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" >
<head runat="server">
    <title>无标题页</title>
   <script lang="javascript">
var initTop=0
  function init()
  {
    initTop=document.getElementById("ali").style.pixelTop;
  }
  function move()
  {
    document.getElementById("ali").style.pixelTop=initTop+document.body.scrollTop;
  }
  window.onscroll=move;
</script> </head><body onLoad="init()"><div id="ali"style="position:absolute;left:1100px;top:120px;z-index:1;">
<a target="_blank" href="http://amos.im.alisoft.com/msg.aw?v=2&uid=hylantian&site=cnalichn&s=5" ><img border="0" src="http://amos.im.alisoft.com/online.aw?v=2&uid=hylantian&site=cnalichn&s=5" alt="点击这里给我发消息" />
</a></div>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<form id="form1" runat="server">
  
</form>
</body>
</html>

解决方案 »

  1.   

    把你执行后的aspx查看源代码跟你本来的可以执行的html比较下,看看主要是哪个不相同。。是不是最上面的 声明<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 有问题?
      

  2.   

    try    var initTop=0
        function init()
        {
            initTop= parseInt(document.getElementById("ali").style.top);
        }
       
        window.onscroll= function(){
            document.getElementById("ali").style.top = (initTop + parseInt(document.documentElement.scrollTop)).toString() + "px";
        }
      

  3.   

    由于<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    直接导致document.body.scrollTop永远等于0,
    所以:用document.documentElement.scrollTop替换document.body.scrollTop就可以了.
    已测试成功哦!!!