Home > Web Front-end > JS Tutorial > body text

js implements dynamically obtaining parameters after the address bar

小云云
Release: 2018-03-26 16:12:52
Original
1825 people have browsed it


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:

  1. 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;  
     }
    Copy after login

##When the url The address is http://114.215.84.2/debo/test.html?code=123

Calling the function will directly return 123.

Benefit at the end of the article:

Benefit one: Front-end, Java, product manager, WeChat applet, Python and other 10G resource collection is released: https://www.jianshu.com/p/e8197d4d9880


Benefit 2: Getting started with WeChat applet and practical experience A full set of detailed video tutorials

[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 receive

Front-end, Java, product manager, WeChat applet, Python and other resources are collected and 10G resources are released.

js implements dynamically obtaining parameters after the address bar


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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!