Jump to content

Get URL to Hash


treeleaf20

Recommended Posts

All,

If I have the following URL:

 

http://example.com/viewpage.php?id=test

 

Then when I write a hash the URL goes to:

 

http://example.com/viewpage.php?id=test#id=nexttest

 

I have the following code:

function redirectHash()
{
var hash = location.hash;
if (hash){
	hash = hash.replace('#', '');
	location.href = hash;
}
}
</script>

Currently this code would try and redirect me to http://example.com/id=nexttest

 

How can I get it so that it keeps everything before the ? and just updates the id part?

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/180867-get-url-to-hash/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.