I pass the url parameter to the social network when clicking the share button as follows:

http://vkontakte.ru/share.php?url=<ссылка>&description... 

But there are situations when, with several entries on one page, an address with an anchor is required ( <ссылка>#<якорь> ). Apparently, the problem is this, since when you try to pass the link in this way, the other parameters are lost (when you send a normal link, everything is fine). Is there any possibility of transferring such links?

  • why don't you use the widget ? - Sergiks

2 answers 2

http://javascript.ru/window-location

Properties of the Location object An example of a page loaded in a browser is google.com:80/search?q=javascript#test

location.hash is the part of the URL that comes after the hash sign '#', including the '#' character #test location.href - the entire URL is google.com:80/search?q=javascript#test

  • That is, there is no way to pass a parameter with a grid symbol to a social network? But what if it is found in the text of the description parameter, for example? - doomek

The answer is found in the encodeURIComponent() function that encodes the special characters passed in the GET parameter.