I have the following URL:
http://www.mywebsite.co.id/?bannerid=1234
What I need is to get the value of "bannerid" from the URL into a variable and then use it in a Javascript. Does anyone know how to grab that value using JavaScript?
I have the following URL:
http://www.mywebsite.co.id/?bannerid=1234
What I need is to get the value of "bannerid" from the URL into a variable and then use it in a Javascript. Does anyone know how to grab that value using JavaScript?
You may be able to access it as part of the <head>
tags, I don't know, and then loop through it as a string to look for your keyword and grab the value after it.
You could use:
window.location.href
to get your URL.
to get the URL, and then use a for
loop to iterate through the string until you come to a b followed by an a, etc..., then grab the numbers after that.
Get current URL in web browser
You might be able to do this by checking the first nine characters for a match, then move one character over and check for a match, etc... until you get to bannerid=
, which would show true, and then you can cut the string there and grab the numbers.
I hope that was clear enough, let me know if you need any more help.