#_=_ added to URL by facebook

三世轮回 提交于 2019-11-27 21:25:33

The #_=_ fragment is being intentionally added by Facebook as described under Change in Sessions Redirect Behavior. Explicitly setting the redirect_uri in your request allegedly takes care of this problem, but there's apparently a bug that persists the unwanted fragment even when the redirect_uri is specified.

Assuming this bug isn't resolved, a workaround may be to replace the hash location using Javascript:

window.location.hash = ""

This doesn't replace the actual hash character, but will get rid of everything following it.

Perhaps this is a cleaner answer and the one I used to solve this issue.

You may have # anchors in your URLs that are desirable and this is especially true if you can end up being forwarded to any page on the site after facebook login. So removing everything in # may cause problems.

This solution will only remove the fubar facebook #= string from the URL and leave other parts of the hash intact.

Add this JS to your header or global JS include.

(function() {
    "use strict";
    if (window.location && window.location.hash) {
        if (window.location.hash === '#_=_') {
            window.location.hash = '';
            return;
        }
        var facebookFubarLoginHash = RegExp('_\=_', 'g');
        window.location.hash = window.location.hash.replace(facebookFubarLoginHash,     '');
    }
}()); 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!