treeleaf20 Posted November 9, 2009 Share Posted November 9, 2009 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 More sharing options...
treeleaf20 Posted November 10, 2009 Author Share Posted November 10, 2009 Also I have that and then call this function when the page loads in the body onload command. It will load the original page and then switch the url and load it again. How can I get it so that it does the url and then load the page? Link to comment https://forums.phpfreaks.com/topic/180867-get-url-to-hash/#findComment-954513 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.