Js gets the values in the page url
First, obtain the parameters through _ window.location
1. Get the complete url of the page
Url = _ window.location.href
2. Get the domain name of the page
Host = _ window.location.host
Host2=document.domain
Application scenario: the page jumps, and the domain names of the development environment and the test environment are different, so you need to dynamically obtain the url that is stitched and redirected.
2. Javascript regularly acquires the parameters in url. 1. Obtain parameters through substr and split.
/ / canonically get the parameter function URL_Request (strName) {var strHref = _ document.location.toString () in url; var intPos = strHref.indexOf ("?"); var strRight = strHref.substr (intPos + 1); / / = get the parameter part on the right var arrTmp = strRight.split ("&"); / / = split into an array for (var I = 0; I < arrTmp.length) by Circular array {var dIntPos = arrTmp [I] .indexOf ("="); var paraName = arrTmp [I] .substr (0, dIntPos); var paraData = arrTmp [I] .substr (dIntPos + 1); if (paraName.toUpperCase () = = strName.toUpperCase ()) {return paraData;}} return ";}
Use:
Var pbtradeId=URL_Request ("tradeId"); 2. Get [update20170503] through split
Function getQueryString (str, key) {if (str) {var queryString = str.split ('?) [1] | |'; var arr = queryString.split ('&') | | []; for (var I = 0; I)