Home > Article > Web Front-end > js implements dynamically obtaining parameters after the address bar
This article mainly shares with you js to dynamically obtain the parameters after the address bar. I hope it can help everyone.
Requirement: js dynamically obtains the parameters behind the address bar
js code:
alert(GetQueryString("code")) //获取地址栏后面的参数 function GetQueryString(name){ var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if(r!=null)return decodeURI(r[2]); return null; }
##When the url The address is http://114.215.84.2/debo/test.html?code=123
[How to receive]
Follow [Programming Micro Journal] WeChat public account: Reply[ Mini program demo] Get 130 WeChat mini program source code demo resources with one click. Reply [Receive resources] One-click to receiveFront-end, Java, product manager, WeChat applet, Python and other resources are collected and 10G resources are released.
A front-end girl born in the 1990s who loves programming, operations, and tossing.Insist on summarizing the technical problems encountered in the work, and insist on recording what you think and see during the work. Everyone is welcome to discuss and exchange together.
The above is the detailed content of js implements dynamically obtaining parameters after the address bar. For more information, please follow other related articles on the PHP Chinese website!