Get current:
var url = window.location.href;
Baidu as an example:
var url=window.location.href;console.info (URL); http://www.jspp.cn/testbin/apptest/app-site/explore.html;
The split () method is used to split a string into an array of strings.
First use Split ('? ') To detach a URL from a parameter:
var url=window.location.href;
var Urlarr = Url.split ('? ');
Console.info (Urlarr);
["Http://www.jspp.cn/testbin/apptest/app-site/explore.html"]
var url=window.location.href; var urlarr = Url.split ('? ');
var k = urlarr[0], Appu = K.split ('/');
Console.log (k);
Console.log (Appu);
Get: VM363:1 http://www.jspp.cn/testbin/apptest/app-site/explore.html
["http:", "" "," www.jspp.cn "," Testbin "," Apptest "," App-site "," explore.html "]
0: "http:"
1: ""
2: "Www.jspp.cn"
3: "Testbin"
4: "Apptest"
5: "App-site"
6: "Explore.html"
Length:7
The last one in the array is the file name:
var L = Appu[appu.length-1];
Console.log (L);//Get the current page name to determine passing parameters
Get: "Explore.html"
JS get url, intercept url parameter, intercept URL after file name