Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Using content preferences

この文書は翻訳中です。他国語のままの部分などがあるのはその為です。
是非お気軽に MDN に登録して翻訳に参加し、私たちの手助けをして下さい!

Firefox 3 は、コンテンツの設定を保存する事ができます。この機能はサイトごとの設定をコンピューターに保存するため chrome 権限が与えられたコードでしか利用できません。言い換えるなら、拡張機能とブラウザ自体(Web サイトを除く)からのみ利用できると言う事です。この機能を使用することで特定の Web サイトをカスタマイズする(例えば文字が小さく読み難いサイトで、文字を大きくする)拡張機能を作成する事ができます。

コンテンツ設定サービスは nsIContentPrefService によってインプリメントされています。この機能を使用して特定の Web サイトに設定したりブラウザの既定設定を割り当てる事ができます。もし特定の Web サイトから設定を取得できない場合はブラウザの既定設定が使用されます。

例: 設定の保存と読み込み

このサンプルは設定を保存した後、保存された設定を読み込んでいます。

var ioSvc = Components.classes["@mozilla.org/network/io-service;1"]
            .getService(Components.interfaces.nsIIOService);
var prefService = Components.classes["@mozilla.org/content-pref/service;1"]
                  .getService(Components.interfaces.nsIContentPrefService);

// Create a URI object referencing the site to save a preference for
var uri = ioSvc.newURI("https://developer.mozilla.org/", null, null);

// Set the value of the "devmo.somesetting" preference to "foo".

prefService.setPref(uri, "devmo.somesetting", "foo");

...

// Retrieve the value of the "devmo.somesetting" preference.

var value = prefService.getPref(uri, "devmo.somesetting");

Built-in site-specific preferences

Preference Name Menu Equivalent Values Notes

browser.content.full-zoom

View / Zoom Example: "1.10000002384186"
(Rounding variant of "1.1")
Related about:config preferences:
  • browser.zoom.full
    Boolean, set by the menu item
    View / Zoom / Zoom Text Only.
    Despite the confusion in names, this preference is not site-specific.
  • browser.zoom.siteSpecific
  • toolkit.zoomManager.zoomValues
  • zoom.maxPercent and zoom.minPercent

browser.download.lastDir

  Path of a filesystem directory Related about:config preferences:
  • browser.download.lastDir
    The last directory for any site

Use DownloadLastDir.jsm for access to these preferences.

browser.upload.lastDir
  Path of a filesystem directory This preference is stored and retrieved automatically by file upload controls.
Gecko 9.0 が必要(Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6)

Private browsing

Prior to Gecko 9.0 (Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6), the content preference service always stores preferences on disk. Because of this, in private browsing mode, use of the content preference service needed to be avoided while in private browsing mode; instead, information needed to be stored in memory or preferences had to be avoided. Starting in Gecko 9.0, when in private browsing mode, the content preference service stores preferences in memory instead of on disk, and automatically forgets them when leaving private browsing mode.

関連情報

ドキュメントのタグと貢献者

タグ: 
 このページの貢献者: ethertank, Mgjbot, Kohei, Norah
 最終更新者: ethertank,