日期:2014-05-16  浏览次数:20444 次

菜鸟刚学javascript,求教script标签引用位置问题
JScript code
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
.scroll_top{
    background-image:url(../images/dd_scroll_top.gif);
    width:540px;
    height:51px;
    background-repeat:no-repeat;
    }
.scroll_mid{
    background-color:#f2f2f3;
    border-left:solid 1px #d6d5d6;
    border-right:solid 1px #d6d5d6;
    width:533px;
    padding:5px 0px 5px 5px;
    }
#dd_scroll{ /*FF*/
    float:none;
    }
*html #dd_scroll{
    float:left; /*IE6*/
    }
*+html #dd_scroll{
    float:left; /*IE7*/
    }
#scroll_number{
    float:right;
    padding-right:10px;
    }
#scroll_number li{
    width:13px;
    height:15px;
    text-align:center;
    border:solid 1px #999;
    margin-top:5px;
    font-size:12px;
    line-height:16px;
    cursor:pointer;
    }
    
    #right{
   top:50px;
   right:30px;
   position:absolute;
   z-index:4;
   text-align:right;
   cursor:pointer;
   }
 .dd_close{
     width:35px;
     height:18px;
     text-align:center;
     border:solid 1px #999;
     background-color:#E0E0E0;
     position:absolute;
     right:0px;
     float:right;
     z-index:5;
     }
/*通栏广告样式*/
.dd_index_top_adver{
    margin:5px 0px 5px 0px;
    clear:both;
    }
    </style>
    
    
    <!--!!!第二个script标签开始-->
    <script type="text/javascript">
    var NowFrame=1;
    var path= new Array();
    path[0]="显示图片11111111111111111111111";
    path[1]="显示图片22222222222222222222222222";
    path[2]="显示图片333333333333333333333";
    path[3]="显示图片44444444444444444444444444";
    path[4]="显示图片555555555555555555555";
    path[5]="显示图片666666666666666666666";
    function show(id){
    if(Number(id)){
        //clearTimeout(theTimer);
        NowFrame=parseInt(id) -1;
    }
    for(var i =0;i< path.length ;i++){
        if(i==NowFrame){
            document.getElementById("dd_scroll").innerHTML=path[i];
            document.getElementById("dd_scroll"+(i+1)).className="scroll_number_over";    //设置当前标题的CSS样式(外部样式表)
        }else{
            document.getElementById("dd_scroll"+(i+1)).className="scroll_number_out";
        }
    }
    
    if(NowFrame == path.length-1){ //设置下一个显示的图片
        NowFrame = 0;
    }else{
        NowFrame++;
    }
}
var theTimer=setInterval('show()', 3000); //设置定时器,显示下一张图片
window.onload=show; //页面加载时运行函数show()

    </script> <!--第二个script标签结束-->

   <!--!!!!第一个script标签开始-->
     <script type="text/javascript">
    var adv;
    var top;
    var left;
    function dd_close(){
      document.getElementById("right").style.display="none";
    }

    function inix(){
    adv=document.getElementById("right");
    if(adv.currentStyle){
        top=parseInt(adv.currentStyle.top);
        left=parseInt(adv.currentStyle.left);
    }else{
        top=parseInt(document.defaultView.getComputedStyle(adv,null).top);
        left=parseInt(document.defaultView.getComputedStyle(adv,null).left);
    }
}

function move(){
    adv.style.top=top+parseInt(document.documentElement.scrollTop)+"px";
    adv.style.left=left+parseInt(document.documentElement.scrollLeft)+"px";
    
}

window.onload=inix;
window.onscroll=move;
    </script> <!--第一个script标签结束-->
</head>

<body>
<div id="right"><div class="dd_close"><a onClick="dd_close()">关闭</a></div>