Reputation: 1077
I'm currently having an interesting issue. I use the Facebook PHP SDK to authenticate users on my website. On my initial request, I pass in a redirect URL, and all works as expected, the users are sent back to the URL specified.
Once on this page, which we will call 'Intermediate Page', they are redirected to my second page, which we will call 'Home Page'. And here, one may notice that an interesting #_=_
is appended to the URL. This issue is discussed here: Facebook Callback appends '#_=_' to Return URL.
I've implemented the JavaScript solution on that page; however, one problem remains. The actual hash part of the URL remains, even though the strange underscore characters are gone. So, and this isn't a massive problem, the URL is now ./home#
.
I've looked at some ways to fix this: How to remove the hash from window.location with JavaScript without page refresh?.
However, apparently these solutions need a page refresh to work. Obviously, this isn't the most efficient and user friendly way to do this.
Now, I thought that since I am, once my user is returned to my 'Intermediate Page', redirecting them once again to my 'Home Page', the refresh part of the operation could be skipped in some way. I could be absolutely wrong though.
So, to conclude: is there a way to remove that remaining hash part of the URL, without actually reloading my 'Intermediate Page', but removing it once I redirect to my 'Home Page'?
EDIT: I am redirecting the user through PHP, using: header('Location: ./home');
.
Upvotes: 3
Views: 2075
Reputation: 16958
This is not actually possible in all browsers using javascript as I have tried to do it in the past. However, you can use HTML 5 to achieve the same thing, this uses the HTML5 History API
function deleteHash(){
// Remove the hash by rewriting URL without it.
history.pushState("",document.title,window.location.pathname + window.location.search);
}
Upvotes: 3