js動態獲取頁面位址

2021-09-02 14:14:41 字數 407 閱讀 2543

在做東西時發現需要獲取動態的位址來實現下滑頁面。所以總結之用,高手勿噴。

var page=2;

var url=document.url; //獲取當前頁面位址的js

var m=url.lastindexof("/");//到最後乙個"/"符號的數目

var base=url.substr(0,m);//到最後乙個"/"符號之前的位址內容

//比如http://localhost:8080/html

if(scrolltop+windowheight-scrollheight<=50),1000);

$.ajax(,

success:function(result),

});finished=1;

}

獲取位址,C 後台根據頁面位址獲取內容

string str1 process.getcurrentprocess mainmodule.filename 可獲得當前執行的exe的檔名。string str2 environment.currentdirectory 獲取和設定當前目錄 即該程序從中啟動的目錄 的完全限定路徑。備註 按照定...

js獲取頁面元素

獲取頁面元素的四種方式 1 通過標籤名來獲取 var box document.getelementsbytagname div 2 console.log box 2 通過class名來獲取 var box2 document.getelementsbyclassname div1 0 conso...

js獲取頁面高度

在我本地測試當中 在ie firefox opera下都可以使用 document.body.clientwidth document.body.clientheight 即可獲得,很簡單,很方便。而在公司專案當中 opera仍然使用 document.body.clientwidth docume...