0
3

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.

【Javascript】5秒後にページ遷移する方法

Last updated at Posted at 2021-04-08

ドメインの変更などで新しいサイトに遷移する方法のメモ

.htaccessでリダイレクトするのが一般的なのですが、
この方法をつかえばページ単位で使うこともできるのと.htaccessの細かい設定をせずに実装できます。

setTimeout(function(){
  window.location.href = 'https://xxxxxx.com';
}, 5*1000);

setTimeoutで秒数を指定。
window.location.hrefで遷移するサイトを指定します。

デメリットはアナリティクスの流入元がすべて前のドメインになることぐらいでしょうか。

0
3
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
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?