拡張機能にローカルデータを渡す方法
setting.js function handleFileSelect(evt) {
var f = evt.target.files[0]
var reader = new FileReader();
reader.onload = function(e){
var data = JSON.parse(e.target.result) // JSONデータをゲット
}
reader.readAsText(f);
}
$(function() {
$('#read').on('change', handleFileSelect);
})
setting.html<input type="file" id="read" accept="application/json">
ボタンを押すとファイル選択ダイヤログが出る
選択すると handleFileSelect()
が呼ばれてデータが data
に書き込まれる
? [Tips]: [ウェブアプリケーション]からの[ファイル]の使用
? [Tips]: (ウェブアプリケーション|Chrome(拡張| extension))で[ローカルデータ]を読む
? [Tips]: (ウェブアプリケーション|Chrome(拡張| extension))から[ローカルデータ]を使う
? [Tips]: (ウェブアプリケーション|Chrome(拡張| extension))に[ローカルデータ]を渡す