0
クロームクッキーを変更するたびに設定する方法はありますか?私はgetRouteを無視 クロムクッキーとHTML selectBox.onchange
<select id="routeBox" name="routeBox"
onchange="getRoute(route, routeBox.selectedIndex);
chrome.cookies.set({'url':'http://127.0.0.1/', 'name':'routeCookie', 'value': this.options.selectedIndex});">
</select>
を試してみた、それだけで選択ボックスを再投入するために、再びXMLパーサを呼び出します。 クッキー部分が機能していないようです。私はonchangeと呼ばれる関数を作成しようとしましたが、どちらも機能しません。
また
<select id="routeBox" name="routeBox"
onchange="getRoute(route, routeBox.selectedIndex);
setCookies('http://127.0.0.1/','routeCookie', this.options.selectedIndex);">
</select>
function setCookies(domain, name, value) {
chrome.cookies.set({'url': domain, 'name': name, 'value': value});
alert("cookie set");
}
:ここに私のマニフェストファイル
"permissions": [
"cookies", "tabs",
"*://*/*"
],
"content_scripts": [
{
"matches": ["http://127.0.0.1/*", "*://*/*"],
"js": ["functions.js"]
}
のスニペットは、任意のヘルプやコメントがいつものようにある素晴らしいだろう!
使用HTML 5のlocalStorage:
なぜlocalStorageを使用しないのですか?グローバル変数を宣言するのと同じように、使い方がはるかに簡単です。 [Googleのドキュメント](http://code.google.com/chrome/extensions/cookies.html#method-set)によると、複数のCookieを設定するためのコンマを訴えることができるとは思えません。セミコロンを試してみるべきだと思います。 –
私は実際には複数のクッキーを設定するのではなく、属性をクッキーに設定しています。ローカルストレージとは何ですか? – infinityLoop
[Dive Into HTML5](http://diveintohtml5.org/storage.html)と[MDN's Docs](https://developer.mozilla.org/en/dom/storage#localStorage)で十分に説明してください。基本的には、HTML5対応ブラウザでページを閉じた後でも、変数を格納する新しい方法です。 Chromeを含みます。 –