1. 程式人生 > >JavaScript懸浮廣告製作注意事項

JavaScript懸浮廣告製作注意事項

<body>
    <div id="div1" style="position:absolute; background-color:#0FF; width:200px; top:0px; height:400px;"><!--代替廣告的div盒子-->
        
    </div>
    <script type="text/javascript">
        function move()
        {
            if(parseInt(document.documentElement.scrollTop)=='')//相容性
            var RealTop=parseInt(document.body.scrollTop); //除了ie 和 firefox 瀏覽器其他的使用這個
            else
            var RealTop=parseInt(document.documentElement.scrollTop);//ieie 和 firefox
            
            
            var left=0;
            
            left+=RealTop;
            div1.style.top=left+'px';
            
            
            }
        setInterval("move()",1);//每0.1秒執行move函式
    </script>
     sdkjj<br><!--為了增加頁面長度而設-->
     sdkjj<br>
     sdkjj<br>sdkjj<br>vsdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>
      sdkjj<br>
     sdkjj<br>
     sdkjj<br>sdkjj<br>vsdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>
     sdkjj<br>sdkjj<br>vsdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>
      sdkjj<br>
     sdkjj<br>
     sdkjj<br>sdkjj<br>vsdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>sdkjj<br>
</body>
</html>