LoginSignup
0
0

More than 3 years have passed since last update.

ページを読み込んだ初回にだけ何かしらの処理を実行する方法

Posted at

実装方法

javaScriptでページ読み込みをしてクッキー情報を更新する。
1日たったらcookieから指定のデータを消す。

if (!document.cookie.match(/name=modal;/)) {
  console.log("クッキーがないからモーダルの処理をします");
}

var one_day = 86400; /* 削除時間を一日の秒数にする */
document.cookie = "name=" + encodeURIComponent('modal'); + "max-age=" + one_day;

・参考サイト
JavaScriptでcookie処理(読み・書き・削除)

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