해당 글은 stackoverflow 에서 추천을 많이 받은 글을 발췌했습니다.

오역은 댓글로 피드백주세요:)


스택 오버플로에 질문글이 올라왔다.


jQuery 를 이용해서 다른페이지로 이동할수있나요?

(How can I redirect the user from one page to another using jQuery?)


다음은 추천을 가장 많이 받은 답변이다. (추천 9690개)


jQuery 를 이용해도 더 간단해지지 않습니다.

(One does not simply redirect using jQuery)


jQuery는 필요하지 않으며 window.location.replace(...) 를 사용하는 방법이 http redirect를 가장 잘 나타냅니다

(jQuery is not necessary, and window.location.replace(...) will best simulate an HTTP redirect.)


이 방법은 window.location.href = 을 사용하는것보다 나은데, 왜냐하면 replace() 는 기존 페이지의 세션 정보를 저장하지 않고, 이것은 사용자가 뒤로가기 버튼을 눌렀을 때 정상적으로 이전 페이지를 불러올 수 없다.

(It is better than using window.location.href =, because replace() does not keep the originating page in the session history, meaning the user won't get stuck in a never-ending back-button fiasco.)


만약 단순히 링크를 클릭하는것을 구현하고싶다면 location.href를 사용하고, HTTP redirect 를 구현하고 싶다면 location.replace.을 써라

(If you want to simulate someone clicking on a link, use location.href. If you want to simulate an HTTP redirect, use location.replace.)



다음은 jQuery 로 사용하는 방법을 어떤분이 올려놓은 답변이다


경고 :이 답변은 가능한 해결책으로 제공되었을뿐입니다. 그것은 jQuery를 필요로하기 때문에 분명히 최선의 해결책은 아닙니다. 대신 순수한 JavaScript 솔루션을 선호하십시오.


WARNING: This answer has merely been provided as a possible solution; it is obviously not the best solution, as it requires jQuery. Instead, prefer the pure JavaScript solution.


$(location).attr('href', 'http://stackoverflow.com')


출처 : http://stackoverflow.com/questions/503093/how-do-i-redirect-to-another-page-in-jquery

+ Recent posts