Getting the full C # tag url

Tried to print the $ _SERVER array in PHP, but I cannot find what I want:

http://www.domain.com/#sometaginpage

I want sometaginpage.

Reference. Thanks!

+6
source share
3 answers

The browser does not actually send the server anything that comes after the hash (#), because it is allowed in the browser.

+9
source

Not sure if #hashtags NOT sent to the server, but you can develop a workaround with AJAX:

some-page.html

 <script type="text/javascript"> $(document).ready(function() { $(window).bind('hashchange', function() { var hash = window.location.hash.substring(1); $.get('ajax-hash.php', { tag: hash }, function(data) { $('#tag').html(data); } ); }); }); </script> <div id="tag"></div> <a href="#one">#one</a> | <a href="#two">#two</a> | <a href="#lolwut">#lolwut</a> 

Ajax-hash.php :

 <?php $hash = isset($_GET['tag']) ? $_GET['tag'] : 'none'; echo $_SERVER['HTTP_REFERER'] . '#' . $hash; ?> 

Note. . It depends on what browser does send HTTP_REFERER . Since this is done through jQuery, it MUST .. but not promises! (Antivirus / firewalls like to remove from your packages)

+3
source

I am not sure if this will provide $ _SERVER ['REQUEST_URI'] or not. s992 may be right, it cannot send this to the server.

0
source

Source: https://habr.com/ru/post/888974/


All Articles