Get URL parameters using Javascript
With PHP, We easily get the URL by $_GET method. With JavaScript is not so easy but you still can do that with function below:
1 2 3 4 5 6 7 8 9 10 | function GetURLParameter(sParam){ var sPageURL = window.location.search.substring(1); var sURLVariables = sPageURL.split('&'); for (var i = 0; i < sURLVariables.length; i++){ var sParameterName = sURLVariables[i].split('='); if (sParameterName[0] == sParam){ return sParameterName[1]; } } } |
Now you can using this function get URL...