train of thought
Front-end development does not have a method to directly obtain URL parameters like the back-end, such as $_GET.
1 |
|
It is more complicated to obtain url parameters at the front end, and js+ regular expressions are needed to read and separate URLs to achieve the method of obtaining parameters.
Get URL parameter method
This is a complete js method to get url parameters
1 2 3 4 5 6 |
|
You can get the value of the parameter by passing the parameter name in the url through this function, for example:
1 |
|
We want to get the value of reurl, we can write like this:
1 |
|
The following is a method of obtaining url parameters written in the jquery library, which is simpler and clearer than native JS.
1 2 3 4 5 6 7 |
|
After extending this method for jQuery, we can get the value of a parameter by the following method:
1 |
|
Both methods can be copied and used directly, and the jquery method needs to refer to the jquery library.