好的,基本上這是我的腳本:
window.onload = () => {
enter code here if ( first_time ) { window.location.href = "www.netlify.app/teamadventures.signup"; } }
我想這樣做,如果這是您第一次訪問該網站,您會自動進入注冊頁面。我如何用香草 JS 做到這一點?
uj5u.com熱心網友回復:
你可以使用cookiesor localStorage。是最localStorage簡單的方法。首先檢查是否有東西存盤在它上面getItem。如果不是,則將此資訊(用戶訪問過的頁面)存盤在localStorage其中并重定向到注冊。
var first_time = localStorage.getItem("first_time");
if (!first_time){
localStorage.setItem("first_time", 1);
window.location.href = "www.netlify.app/teamadventures.signup";
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/419160.html
標籤:
