Possible Duplicate:
How to get “GET” request parameters in JavaScript?
jQuery querystring
How can I get query string values in JavaScript?
Javascript does not provide a core method to do that, so how to do it?
Answer : You can control if the Source URL parameters are copied to the Destination URL. The Site Preference is : Business Manager > site > Merchant Tools > Site Preferences > Storefront URLs > Copy Source Parameters.
The short answer is yes Javascript can parse URL parameter values. You can do this by leveraging URL Parameters to: Pass values from one page to another using the Javascript Get Method. Pass custom values to Google Analytics using the Google Tag Manager URL Variable which works the same as using a Javascript function.
Any word after the question mark (?) in a URL is considered to be a parameter which can hold values. The value for the corresponding parameter is given after the symbol "equals" (=). Multiple parameters can be passed through the URL by separating them with multiple "&".
For getting the URL parameters, there are 2 ways: By using the URLSearchParams Object. By using Separating and accessing each parameter pair.
function getURLParameter(name) { return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [null, ''])[1].replace(/\+/g, '%20')) || null; }
So you can use:
myvar = getURLParameter('myvar');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With