0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

meta要素を使って画面遷移させる

Last updated at Posted at 2021-05-19

調べた経緯

「ページにアクセスされた時点から5分経過したらログイン画面へリダイレクトさせたい」という要望があったので、実装方法を調べてみました。
当初、javascriptでsetTimeoutを使うかと思っていたのですが、meta要素を使って簡単にできたので、備忘録として残しておきます。

書き方

<meta http-equiv="Refresh" content="{時間を秒で指定}; url={urlを指定}">

これに当てはめてみると、

としたいとき、

<meta http-equiv="Refresh" content="300; url='http://www.example.com/'">

このようになります!

これで5分経過後、http://www.example.com/にリダイレクトされます。

注意点

Googleはmeta refreshによるリダイレクトをサポートしているものの推奨してはいません。
(301リダイレクトが推奨されています。)
SEO的にも良くないようです。

今回はSEO対策も不要で、且つサーバーサイドで処理することもできなかったので。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?