LoginSignup
3
1

More than 5 years have passed since last update.

Chrome ローカル環境で localStorageを使う

Posted at

準備

コンテンツの設定 -> Cookie -> 例外設定
file:///* を許可

jsで使えるかチェック

window.onload = function(){
    if (storageCheck('localStorage')) {
        // 使える場合
    } else {
        // 使えない場合
    }
}

function storageCheck(type){
    try {
        var storage = window[type],
        x = '__test__';
        storage.setItem(x,x);
        storage.removeItem(x);
        return true;
    } catch(e) {
        return false;
    }
}

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