Post

(HTML, JS) refresh / redirect

사실 HTML과 JS를 이용해 redirect하는 것 보다 서버 측에서 HTTP redirection status code(301, 302)를 보내 redirect하도록 하는 것이 더 좋다.

2017/06/08 - [Web/Back-end] - [PHP] HTTP response header 수정

JS를 이용하면 JS가 비활성화 되어 있는 경우 제대로 동작하지 않으니 JS보다는 HTML을 사용한 방법이 나은 것 같다.

HTML

1
2
3
refresh  : <meta http-equiv="refresh" content="5" />
redirect : <meta http-equiv="refresh" content="0; url=http://www.example.com/" />

content에 url이 한꺼번에 들어간다는 것에 유의.

JS

1
2
3
refresh  : location.reload()
redirect : location.href='http://www.example.com/'

This post is licensed under CC BY 4.0 by the author.