General Get methods:
var protocol = Window.location.protocol; "http:"
var host = Window.location.host; "localhost" or "www.baidu.com"
var pathname = Window.location.pathname; "/dkrl/services/cases.php"
var href = window.location.href; "Http://localhost/dkrl/services/cases.php?noId=7"
var search = Window.location.search; "? noid=7"
Use JS to get the current page name
var strurl = window.location.href;
var arrurl = Strurl.split ("/");
var strpage = arrurl[arrurl.length-1];
var indexof = Strpage.indexof ("?");
if (indexof! =-1) {
Strpage = Strpage.substr (0,strpage.indexof ("?"));
}
alert (strpage);
Regular Fetch method:
Match any character (. *)
The substitution of JS strings and the use of the Replace () method
The Replace (Regexp,replacement) method has two parameters, the first parameter can be a plain text string or a RegExp object, see the use of RegExp object, the second parameter is a string can also be a function.
The following is an example of JS string substitution:
Example 1:
var str= "Hello world!";
document.write (Str.replace (/world/, "Phper"));
Example 2:
var reg=new RegExp ("(\\w+), (\\d+), (\\w+)", "GMI");
var info= "Lili,14,china";
var rep=info.replace (Reg, "She is $ $, $ years old, come from $");
Alert (rep);
JS get URL path includes regular match rule to get