隨筆-167  評論-65  文章-0  trackbacks-0
          我們知道window onload或者body的onload方法,都是在頁面加載完后才執行的,也就像是組最后執行的js方法,那么如何讓我需要的js function 最后執行呢,或者定義其執行順序,那就需要用到,setTimeout方法了

          使用方法demo:
            <script>
              
          function getaddress(){ // set address from DB
                var province_db = document.getElementById('province_value').value;
                
          var city_db = document.getElementById('city_value').value;

                
          with(document.userinfo.province) {var loca2 = province_db; }
                
          for(i = 0;i < where.length;i ++) {
                  
          if (where[i].loca == loca2) {
                    loca3 
          = (where[i].locacity).split("|");
                    
          for(j = 1;j < loca3.length;j++)
                    { 
          with(document.userinfo.city){ length = loca3.length; options[j].text = loca3[j]; options[j].value = loca3[j];}}
                    
          break;
                  }
                }
                
          var length = document.userinfo.province.length;
                
          var length_city = document.userinfo.city.length;
                
          for(i = 0; i < length;i++){
                  
          if(document.getElementById('province').options[i].value == province_db){
                    document.getElementById('province').selectedIndex 
          = i;
                  }
                }
                
          for(i = 0 ; i< length_city;i++){
                  
          if(document.getElementById('city').options[i].value == city_db){
                    document.getElementById('city').selectedIndex 
          = i;
                  }
                }

              }
              setTimeout(
          "getaddress()"1000);
          </script>

          setTimeout(函數,時間) 意為延遲執行的時間,只執行一次

          ref:
          http://blog.csdn.net/lne818/archive/2008/03/03/2143753.aspx



          write by feng
          posted on 2009-06-16 18:55 fl1429 閱讀(264) 評論(0)  編輯  收藏 所屬分類: Ajax

          <2009年6月>
          31123456
          78910111213
          14151617181920
          21222324252627
          2829301234
          567891011

          常用鏈接

          留言簿(6)

          隨筆分類(173)

          隨筆檔案(165)

          Links

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          已訪問數:
          free counters
          主站蜘蛛池模板: 三台县| 福鼎市| 甘南县| 江川县| 肃宁县| 都江堰市| 抚顺县| 乡城县| 太保市| 张家港市| 海南省| 盐城市| 依兰县| 珲春市| 翁牛特旗| 乳山市| 襄汾县| 台北县| 成都市| 渑池县| 鄱阳县| 西乌珠穆沁旗| 平度市| 南宫市| 盐边县| 昌图县| 祥云县| 牡丹江市| 合作市| 崇仁县| 仁布县| 河间市| 定南县| 施甸县| 保定市| 乌拉特中旗| 东兰县| 澄迈县| 芦山县| 周至县| 牟定县|