facebook login redirect #_=_ code example
Example 1: Why is #_=_ appended to the redirect URI? passport facebook
<html xmlns:fb='http://www.facebook.com/2008/fbml'>
<head>
<script type="text/javascript">
if (String(window.location.hash).substring(0,1) == "#") {
window.location.hash = "";
window.location.href=window.location.href.slice(0, -1);
}
if (String(location.hash).substring(0,1) == "#") {
location.hash = "";
location.href=location.href.substring(0,location.href.length-3);
}
</script>
</head>
<body>
URI should be clean
</body>
</html>
Example 2: Why is #_=_ appended to the redirect URI? passport facebook
if (window.location.hash && window.location.hash === "#_=_") {
if (Modernizr.history) {
window.history.pushState("", document.title, window.location.pathname);
} else {
var scroll = {
top: document.body.scrollTop,
left: document.body.scrollLeft
};
window.location.hash = "";
document.body.scrollTop = scroll.top;
document.body.scrollLeft = scroll.left;
}
}
Example 3: Why is #_=_ appended to the redirect URI? passport facebook
$(window).on('load', function(e){
if (window.location.hash == '#_=_') {
window.location.hash = '';
history.pushState('', document.title, window.location.pathname);
e.preventDefault();
}
})