Get hash # from URL address

Discuss coding issues, and scripts related to PHP and MySQL.
User avatar
JanMolendijk
Posts:282
Location:Holland Rotterdam

Get hash # from URL address

Plessant Coursesweb

I have in this url standing an hash

Code: Select all

//145.53.93.209/Molendijk/home/read.php?id=<?php echo  $row['topic_id']?>#<?php echo $row['over_all_id'] ?>
But I dont how to get this hash into setTimeout(function

Code: Select all

<?php 
$id = (int) $_GET['id'];

$# = (int) $_GET['#'];

$title = (int) $_GET['title'];
?>

Code: Select all

 <script>
setTimeout(function(){
  window.location.href = "//145.53.93.209/Jan-Molendijk/_new-topic.php?id=<?php echo $id ?>#<?php echo $# ?>";
}, 1);
</script>
Hope you have an answer for me.

MarPlo Posts:186
To get the "hash" from current url address in javascript, use the hash propertty

Code: Select all

<script>
//set the hash
window.location.hash ='hsh';

//get part after #
let hash_url = window.location.hash.replace('#', '');
alert(hash_url)
</script>
But in PHP you cannot get the hash from page url. The part after the # isn't being sent to the server, so you can't parse it through PHP.

Similar Topics