The receiving and recording data in the url. How to do?

Make the reflector of subscribers in the group VK.

The script is made in such a way that there is a pre-defined group and it is shown if the user did his entered.

When the page is loaded the url will change to the group ID. Here it is:

local/live/vk.php?id=public121472159

Also there is a field. If a person enters your group, it shows the info on it and the url changes accordingly.
I would like to implement such a thing.

Will try to explain. Since the address is generated for a specific user, how to give him the opportunity to share it with your friends, for example? That is, he enters the address

http://local/live/vk.php?id=бла-бла-бла

And gets the old band blah-blah-blah. That is to take the id from the url.

But if there is no id parameter, take the default value...

I hope at least a little bit understandable. I would be very grateful for your help!!!
July 9th 19 at 13:43
2 answers
July 9th 19 at 13:45
It is not clear, and here JavaScript, in fact, the GET-request you need to handle on the server such as PHP;
<?php
echo $_GET['id'];
?>

But you can on the client using JavaScript to parse the window.location.href
The fact that all this is implemented without rebooting and the data comes from Ajax json - Fabian.Wiegand commented on July 9th 19 at 13:48
Well what the problem is, window.location.href and basic parsing of the string. - mazie.Towne commented on July 9th 19 at 13:51
July 9th 19 at 13:47
function QueryString (name) {
 if (name == null || name == "") return "";
 var result = "";
 var href = window.location.href;
 if (href.indexOf("?") != -1) {
 var query = href.substr(href.indexOf("?"));
 var queryParam = query.split("&");
 for (var n = 0; n < queryParam.length; n++)
 if (queryParam[n].toLowerCase().indexOf(name.toLowerCase() + "=") != -1) {
 result = queryParam[n].split("=")[1];
break;
}
}
 return unescape(result);
}

Find more questions by tags JavaScriptHTMLjQuery