乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      JavaScript獲取當前文件全路徑、當前目錄、當前文件名

       madoutupiancom 2016-12-30
      //獲取當前文件全路徑
      <script language="javascript"
      alert(window.location.href);     //
      alert(window.location);         //
      alert(location.href);             //
      alert(parent.location.href);         //
      alert(top.location.href);             
      alert(document.location.href); 
      alert(document.URL);
      </script>
      //獲取當前目錄方法
      <script type="text/javascript">
      //方法一
      var str = location.href;
      var arr = str.split("/");
      delete arr[arr.length-1];
      var dir = arr.join("/");
      alert(dir);
      //方法二
      alert(location.href.substring(0,location.href.lastIndexOf('/')));
      </script>
      //獲取當前文件名
      <script   language=javascript>   
      var  filename=location.href;
      filename=filename.substr(filename.lastIndexOf('/')+1);   
      alert(filename);   
      </script>
      如何用js得到當前頁面的url信息方法(JS獲取當前網址信息)    
      設置或獲取對象指定的文件名或路徑。
      alert(window.location.pathname)
        
      設置或獲取整個 URL 為字符串。
        
      alert(window.location.href);
      設置或獲取與 URL 關聯(lián)的端口號碼。
      alert(window.location.port)
        
      設置或獲取 URL 的協(xié)議部分。
      alert(window.location.protocol)
        
      設置或獲取 href 屬性中在井號“#”后面的分段。
      alert(window.location.hash)
        
      設置或獲取 location 或 URL 的 hostname 和 port 號碼。
      alert(window.location.host)
        
      設置或獲取 href 屬性中跟在問號后面的部分。
      alert(window.location.search)
        
        
      獲取變量的值(截取等號后面的部分)
      var url = window.location.search;
      alert(url.length);
      alert(url.lastIndexOf('='));
      var loc = url.substring(url.lastIndexOf('=')+1, url.length);
      JS獲取當前網址,JS獲取當前域名URL ,JS獲取網站完整路徑頁面地址
      1.獲取當前完整網址
      thisURL = document.URL; 
      thisHREF = document.location.href; 
      thisSLoc = self.location.href; 
      thisDLoc = document.location; 
      strwrite = " thisURL:  [" + thisURL + "]<br />" 
      strwrite += " thisHREF:  [" + thisHREF + "]<br />" 
      strwrite += " thisSLoc:  [" + thisSLoc + "]<br />" 
      strwrite += " thisDLoc:  [" + thisDLoc + "]<br />" 
      document.write( strwrite );
      2.獲取當前域名信息
      thisTLoc = top.location.href; 
      thisPLoc = parent.document.location; 
      thisTHost = top.location.hostname; 
      thisHost = location.hostname; 
      strwrite = "  thisTLoc:  [" + thisTLoc + "]<br />" 
      strwrite += " thisPLoc:  [" + thisPLoc + "]<br />" 
      strwrite += " thisTHost:  [" + thisTHost + "]<br />" 
      strwrite += " thisHost:  [" + thisHost + "]<br />" 
      document.write( strwrite );
      3.獲取當前頁面
      tmpHPage = thisHREF.split( "/" ); 
      thisHPage = tmpHPage[ tmpHPage.length-1 ]; 
      tmpUPage = thisURL.split( "/" ); 
      thisUPage = tmpUPage[ tmpUPage.length-1 ]; 
      strwrite = " thisHPage:  [" + thisHPage + "]<br />" 
      strwrite += " thisUPage:  [" + thisUPage + "]<br />" 
      document.write( strwrite );

        本站是提供個人知識管理的網絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內容,請點擊一鍵舉報。
        轉藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多