본문 바로가기

퍼블리싱/기타정보

페이스북 로그인 #_=_ 제거하기

사이트에 페이스북 로그인을 붙였는데, 로그인을 한 이후에 url주소에 저 요성한 특수문자로 리다이렉션이 붙는다. 그래도 데이터만 잘나오면 괜찮다고 생각했는데, 불행이도 일부 콘텐츠가 안나오거나 이상하게 나오는 현상이 보인다. ㅜ

그래서 저 특수문자를 제거해보려한당

검색해보니 나만 발생하는 문제는 아니였던것 같고, 꽤 오래전부터 이런문제가 발생했던것 같은데, 페이스북에서 제공한 해결책으로 해결되지 않는것 같다.

그런데 그냥 심플하게 리다이렉션 된 주소를 다시 바뀌주기면 하면 다시 제대로 돌아온다.

 

<사용한 코드>

1
2
if (window.location.hash && window.location.hash == '#_=_') { 
window.location.hash = ''; }
 
 

요렇게 넣어주면 끝!

 

저는 됐는데 안됐다면 다른 코드

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
if (window.location.hash && window.location.hash === "#_=_") {
  // If you are not using Modernizr, then the alternative is:
  //   `if (window.history && history.pushState) {`
  if (Modernizr.history) {
    window.history.pushState(""document.title, window.location.pathname);
  } else {
    // Prevent scrolling by storing the page's current scroll offset
    var scroll = {
      top: document.body.scrollTop,
      left: document.body.scrollLeft
    };
    window.location.hash = "";
    // Restore the scroll offset, should be flicker free
    document.body.scrollTop = scroll.top;
    document.body.scrollLeft = scroll.left;
  }
}