Overlay

An overlay is used when it is desirable for a block of content to be shared between several different windows. In addition, it can be used to append or alter content in an existing window. An overlay is defined in a separate XUL file. Overlays are applied while the XUL is being loaded.

Each element within the overlay is inserted at a location in the master window, determined by matching id attributes. For instance, if an element in an overlay has an id of 'filemenu', the corresponding element with the id 'filemenu' in the master window that uses the overlay would be altered. Attributes declared in the overlay are added to that element and child elements are inserted into the window within that element. Elements directly inside the overlay element as children that do not have id attributes are appended to the master window. This allows the addition of scripts to the master window from the overlay.

Overlays do not have an onload event. To have initialization code in an overlay, place it directly in a script outside of a function. This is commonly used to call the addEventListener method to listen to the load event for the window which does not fire until the master window and all overlays are applied.

Overlays may be applied to windows in other packages. Files, such as scripts, that are referenced from the overlay should be specified as absolute URLs. If you do specify a relative URL, it will be relative to the window that the overlay applies to, not the overlay's file.

More information about overlay

オーバーレイはいくつかのウインドウで内容を共用することが望まれる場合に利用される。加えて、存在するウインドウに対し、内容を追加したり変更することにも利用できる。オーバーレイは別個の XUL ファイルで定義される。オーバーレイは XUL が読み込まれる段階で適用される。

オーバーレイにある要素はそれぞれ、マスターとなるウィンドウ内の、 id 属性の一致で決まる場所に挿入される。例えば、オーバーレイのある要素が 'filemenu' という id を持つとき、そのオーバーレイを使用するマスターウィンドウ内の 'filemenu' id を持つ対応要素が選択される。オーバーレイで定義された属性はその要素に追加され、子要素はその要素内のウィンドウに挿入される。 id 属性を持たない子要素として overlay 要素内に直接置かれた要素は、マスターウィンドウに追加される。これにより、オーバーレイからマスターウィンドウにスクリプトを追加することができる。

オーバーレイは onload イベントを持たない。オーバーレイに初期化コードを置くには、関数外部のスクリプトに直接置く。これは、ウィンドウのロードイベントを取得する (listen) ために addEventListener メソッドを呼び出す、よく使われる方法です。このロードイベントは、マスターウィンドウと全てのオーバーレイが適用されるまで送出されません (not fire)。

他のパッケージのウィンドウにも、オーバーレイを適用することができる。オーバーレイから参照される、スクリプトとかのファイルは、絶対 URL で指定する必要がある。相対 URL で指定した場合、オーバーレイが適用するウィンドウからの相対になってしまい、オーバーレイのファイルからの相対にはならない。

overlay の追加情報

属性:

class id

属性:

class

Type: string

The style class of the overlay. Multiple classes may be specified by separating them with spaces.

型 : string

オーバーレイのスタイルクラス。スペースで区切ることで、複数のクラスを指定することができる。

id

Type: element id, must be unique in the window

A unique identifier so that you can identify the overlay with. You can use this as a parameter to getElementById and other DOM functions and to reference the element in style sheets.

型 : element id, must be unique in the window

ユニークな識別子。これによりオーバーレイを識別することができる。 getElementById や他の DOM 関数へのパラメータとして、またスタイルシートの要素を参照するパラメータとして、これを使用することができる。


Copyright (C) 1999 - 2004 XulPlanet.com