Site Notice

hello, world

Difference between revisions of "Get URL param"

From Project-EPB Commons
([InPageEdit] 没有编辑摘要)
 
([InPageEdit] 没有编辑摘要)
 
Line 1: Line 1:
<source lang="javascript">function getUrlParam(url,param) {
+
<pre>function getUrlParam(url,param) {
 
   var url = new URL(url),
 
   var url = new URL(url),
 
       param = url.searchParams.get(param);
 
       param = url.searchParams.get(param);
 
   return param;
 
   return param;
}</source>
+
}</pre>
 +
该方法在主流浏览器上均可运作,除了万恶的IE……

Latest revision as of 20:08, 8 November 2019

function getUrlParam(url,param) {
  var url = new URL(url),
      param = url.searchParams.get(param);
  return param;
}

该方法在主流浏览器上均可运作,除了万恶的IE……