다른 웹페이지로 리디렉트하는 것은 어떻게 하나요?

LONGNEW·2021년 1월 4일
0

StackOverFlaw

목록 보기
11/16

Q. How do I redirect to another webpage?
Q. 다른 웹페이지로 리디렉트하는 것은 어떻게 하나요?
How can I redirect the user from one page to another using jQuery or pure JavaScript?
JQuery나 JacaScript로 사용자가 한 웹페이지에서 다른 곳으로 리디렉트 하도록 어떻게 하나요??


One does not simply redirect using jQuery

단순히 jQuery만으로 리디렉트 하지 않습니다.
jQuery is not necessary, and window.location.replace(...) will best simulate an HTTP redirect.
jQuery는 필수 적이지 않고. window.location.replace(...)이 코드가 HTTP를 리디렉트하기에 가장 좋습니다.
window.location.replace(...) is better than using window.location.href,
window.location.replace(...)을 쓰는 것이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.
왜냐하면, replace()가 원래의 페이지를 기록에 남기지 않게 때문인데. 사용자가 계속 뒤로가기를 눌러야 하는것을 겪지 않게 만들어준다.

If you want to simulate someone clicking on a link, use location.href
만약 다른사람이 링크를 눌러서 다른 페이지로 이동하도록 하고 싶다면.location.href 코드를
If you want to simulate an HTTP redirect, use location.replace
HTTP 리디렉트를 하고 싶은 경우엔, location.replace코드를 이용하는 것이 좋다.
For example:

// similar behavior as an HTTP redirect
window.location.replace("http://stackoverflow.com");

// similar behavior as clicking on a link
window.location.href = "http://stackoverflow.com";

0개의 댓글