JavaScript语言参考手册      
JavaScript手册
【目录】 【上一页】 【下一章】 【索引】

Layer

Corresponds to a layer in an HTML page and provides a means for manipulating that layer.

客户端对象
实现版本Navigator 4.0

创建源

The HTML LAYER or ILAYER tag, or using cascading style sheet语法. The JavaScript runtime engine creates a Layer object corresponding to each layer in your document. It puts these objects in an array in the document.layers property. You access a Layer object by indexing this array.

To define a layer, use standard HTML语法. If you specify the ID attribute, you can use the value of that attribute to index into the layers array.

For a complete描述 of layers, see Dynamic HTML in Netscape Communicator1.

Some layer properties can be directly modified by assignment; for example, "mylayer.visibility = hide". A layer object also has methods that can affect these properties.

事件句柄

属性概览

aboveThe layer object above this one in z-order, among all layers in the document or the enclosing window object if this layer is topmost.
backgroundThe image to use as the background for the layer's canvas.
bgColorThe color to use as a solid background color for the layer's canvas.
belowThe layer object below this one in z-order, among all layers in the document or null if this layer is at the bottom.
clip.bottomThe bottom edge of the clipping rectangle (the part of the layer that is visible.)
clip.heightThe height of the clipping rectangle (the part of the layer that is visible.)
clip.leftThe left edge of the clipping rectangle (the part of the layer that is visible.)
clip.rightThe right edge of the clipping rectangle (the part of the layer that is visible.)
clip.topThe top edge of the clipping rectangle (the part of the layer that is visible.)
clip.widthThe width of the clipping rectangle (the part of the layer that is visible.)
documentThe layer's associated document.
leftThe horizontal position of the layer's left edge, in pixels, relative to the origin of its parent layer.
nameA string specifying the name assigned to the layer through the ID attribute in the LAYER tag.
pageXThe horizontal position of the layer, in pixels, relative to the page.
page yThe vertical position of the layer, in pixels, relative to the page.
parentLayerThe layer object that contains this layer, or the enclosing window object if this layer is not nested in another layer.
siblingAboveThe layer object above this one in z-order, among all layers that share the same parent layer, or null if the layer has no sibling above.
siblingBelowThe layer object below this one in z-order, among all layers that share the same parent layer, or null if layer is at the bottom.
srcA string specifying the URL of the layer's content.
topThe vertical position of the layer's top edge, in pixels, relative to the origin of its parent layer.
visibilityWhether or not the layer is visible.
zIndexThe relative z-order of this layer with respect to its siblings.

方法概览

captureEventsSets the window or document to capture all events of the specified type.
handleEvent调用指定事件的控制句柄。
loadChanges the source of a layer to the contents of the specified file, and simultaneously changes the width at which the layer's HTML contents will be wrapped.
moveAboveStacks this layer above the layer specified in the argument, without changing either layer's horizontal or vertical position.
moveBelowStacks this layer below the specified layer, without changing either layer's horizontal or vertical position.
moveByChanges the layer position by applying the specified deltas, measured in pixels.
moveToMoves the top-left corner of the window to the specified screen coordinates.
moveToAbsoluteChanges the layer position to the specified pixel coordinates within the page (instead of the containing layer.)
releaseEventsSets the layer to release captured events of the specified type, sending the event to objects further along the event hierarchy.
resizeByResizes the layer by the specified height and width values (in pixels).
resizeToResizes the layer to have the specified height and width values (in pixels).
routeEventPasses a captured event along the normal event hierarchy.

Note

Just as in the case of a document, if you want to define mouse click response for a layer, you must capture onMouseDown and onMouseUp events at the level of the layer and process them as you want.

See "Events in Navigator 4.0" for more details about capturing events.

If an event occurs in a point where multiple layers overlap, the topmost layer gets the event, even if it is transparent. However, if a layer is hidden, it does not get events.

属性

above

The layer object above this one in z-order, among all layers in the document or the enclosing window object if this layer is topmost.

属性源Layer
只读
实现版本Navigator 4.0

background

The image to use as the background for the layer's canvas (which is the part of the layer within the clip rectangle).

属性源Layer
实现版本Navigator 4.0

描述

Each layer has a background property, whose value is an image object, whose src attribute is a URL that indicates the image to use to provide a tiled backdrop. The value is null if the layer has no backdrop. For example:

layer.background.src = "fishbg.gif";

bgColor

A string specifying the color to use as a solid background color for the layer's canvas (the part of the layer within the clip rectangle).

属性源Layer
实现版本Navigator 4.0

描述

The bgColor property is expressed as a hexadecimal RGB triplet or as one of the string literals listed in the JavaScript Guide. This property is the JavaScript reflection of the BGCOLOR attribute of the BODY tag.

You can set the bgColor property at any time.

If you express the color as a hexadecimal RGB triplet, you must use the format rrggbb. For example, the hexadecimal RGB values for salmon are red=FA, green=80, and blue=72, so the RGB triplet for salmon is "FA8072".

示例

The following example sets the background color of the myLayer layer's canvas to aqua using a string literal:

myLayer.bgColor="aqua" The following example sets the background color of the myLayer layer's canvas to aqua using a hexadecimal triplet:

myLayer.bgColor="00FFFF"

参看

Layer.bgColor

below

The layer object below this one in z-order, among all layers in the document or null if this layer is at the bottom.

属性源Layer
只读
实现版本Navigator 4.0

clip.bottom

The bottom edge of the clipping rectangle (the part of the layer that is visible.) Any part of a layer that is outside the clipping rectangle is not displayed.

属性源Layer
实现版本Navigator 4.0

clip.height

The height of the clipping rectangle (the part of the layer that is visible.) Any part of a layer that is outside the clipping rectangle is not displayed.

属性源Layer
实现版本Navigator 4.0

clip.left

The left edge of the clipping rectangle (the part of the layer that is visible.) Any part of a layer that is outside the clipping rectangle is not displayed.

属性源Layer
实现版本Navigator 4.0

clip.right

The right edge of the clipping rectangle (the part of the layer that is visible.) Any part of a layer that is outside the clipping rectangle is not displayed.

属性源Layer
实现版本Navigator 4.0

clip.top

The top edge of the clipping rectangle (the part of the layer that is visible.) Any part of a layer that is outside the clipping rectangle is not displayed.

属性源Layer
实现版本Navigator 4.0

clip.width

The width of the clipping rectangle (the part of the layer that is visible.) Any part of a layer that is outside the clipping rectangle is not displayed.

属性源Layer
实现版本Navigator 4.0

document

The layer's associated document.

属性源Layer
只读
实现版本Navigator 4.0

描述

Each layer object contains its own document object. This object can be used to access the images, applets, embeds, links, anchors and layers that are contained within the layer. Methods of the document object can also be invoked to change the contents of the layer.

left

The horizontal position of the layer's left edge, in pixels, relative to the origin of its parent layer.

属性源Layer
实现版本Navigator 4.0

name

A string specifying the name assigned to the layer through the ID attribute in the LAYER tag.

属性源Layer
只读
实现版本Navigator 4.0

pageX

The horizontal position of the layer, in pixels, relative to the page.

属性源Layer
实现版本Navigator 4.0

pageY

The vertical position of the layer, in pixels, relative to the page.

属性源Layer
实现版本Navigator 4.0

parentLayer

The layer object that contains this layer, or the enclosing window object if this layer is not nested in another layer.

属性源Layer
只读
实现版本Navigator 4.0

siblingAbove

The layer object above this one in z-order, among all layers that share the same parent layer or null if the layer has no sibling above.

属性源Layer
只读
实现版本Navigator 4.0

siblingBelow

The layer object below this one in z-order, among all layers that share the same parent layer or null if layer is at the bottom.

属性源Layer
只读
实现版本Navigator 4.0

src

A URL string specifying the source of the layer's content. Corresponds to the SRC attribute.

属性源Layer
实现版本Navigator 4.0

top

The top property is a synonym for the topmost Navigator window, which is a document window or web browser window.

属性源Layer
只读
实现版本Navigator 4.0

描述

The top property refers to the topmost window that contains frames or nested framesets. Use the top property to refer to this ancestor window.

The value of the top property is

<object objectReference> where objectReference is an internal reference.

示例

The statement top.close() closes the topmost ancestor window.

The statement top.length specifies the number of frames contained within the topmost ancestor window. When the topmost ancestor is defined as follows, top.length returns three:

<FRAMESET COLS="30%,40%,30%">
<FRAME SRC=child1.htm NAME="childFrame1">
<FRAME SRC=child2.htm NAME="childFrame2">
<FRAME SRC=child3.htm NAME="childFrame3">
</FRAMESET>

visibility

Whether or not the layer is visible.

属性源Layer
实现版本Navigator 4.0

描述

A value of show means show the layer; hide means hide the layer; inherit means inherit the visibility of the parent layer.

zIndex

The relative z-order of this layer with respect to its siblings.

方法源Layer
实现版本Navigator 4.0

描述

Sibling layers with lower numbered z-indexes are stacked underneath this layer. The value of zIndex must be 0 or a positive integer.

方法

captureEvents

Sets the window or document to capture all events of the specified type.

方法源Layer
实现版本Navigator 4.0

语法

captureEvents(eventType)

参数

eventTypeType of event to be captured. Available event types are listed with event.

描述

When a window with frames wants to capture events in pages loaded from different locations (servers), you need to use captureEvents in a signed script and precede it with enableExternalCapture. For more information and an example, see enableExternalCapture.

captureEvents works in tandem with releaseEvents, routeEvent, and handleEvent. For more information, see "Events in Navigator 4.0".

handleEvent

调用指定事件的控制句柄。

方法源Layer
实现版本Navigator 4.0

语法

handleEvent(event)

参数

eventName of an event for which the specified object has an event handler.

描述

handleEvent works in tandem with captureEvents, releaseEvents, and routeEvent. For more information, see "Events in Navigator 4.0".

load

Changes the source of a layer to the contents of the specified file and simultaneously changes the width at which the layer's HTML contents are wrapped.

方法源Layer
实现版本Navigator 4.0

语法

load(sourcestring, width)

参数

sourcestringA string indicating the external file name.
widthThe width of the layer as a pixel value.

moveAbove

Stacks this layer above the layer specified in the argument, without changing either layer's horizontal or vertical position. After re-stacking, both layers will share the same parent layer.

方法源Layer
实现版本Navigator 4.0

语法

moveAbove(aLayer)

参数

aLayerThe layer above which to move the current layer.

moveBelow

Stacks this layer below the specified layer, without changing either layer's horizontal or vertical position. After re-stacking, both layers will share the same parent layer.

方法源Layer
实现版本Navigator 4.0

语法

moveBelow(aLayer)

参数

aLayerThe layer below which to move the current layer.

moveBy

Changes the layer position by applying the specified deltas, measured in pixels.

方法源Layer
实现版本Navigator 4.0

语法

moveBy(horizontal, vertical)

参数

horizontalThe number of pixels by which to move the layer horizontally.
verticalThe number of pixels by which to move the layer vertically.

moveTo

Moves the top-left corner of the window to the specified screen coordinates.

方法源Layer
实现版本Navigator 4.0

语法

moveTo(x-coordinate, y-coordinate)

参数

x-coordinate An integer representing the top edge of the window in screen coordinates.
y-coordinateAn integer representing the left edge of the window in screen coordinates.

安全性

To move a window offscreen, call the moveTo method in a signed script. 要获取 Navigator 4.0 中关于安全性更多的信息,请看“JavaScript 指南”中的第七章“JavaScript 安全性”

描述

Changes the layer position to the specified pixel coordinates within the containing layer. For ILayers, moves the layer relative to the natural inflow position of the layer.

参看

Layer.moveBy

moveToAbsolute

Changes the layer position to the specified pixel coordinates within the page (instead of the containing layer.)

方法源Layer
实现版本Navigator 4.0

语法

moveToAbsolute(x, y)

参数

xAn integer representing the top edge of the window in pixel coordinates.
yAn integer representing the left edge of the window in pixel coordinates.

描述

This method is equivalent to setting both the pageX and pageY properties of the layer object.

releaseEvents

Sets the window or document to release captured events of the specified type, sending the event to objects further along the event hierarchy.

方法源Layer
实现版本Navigator 4.0

语法

releaseEvents(eventType)

参数

eventTypeType of event to be captured.

描述

If the original target of the event is a window, the window receives the event even if it is set to release that type of event. releaseEvents works in tandem with captureEvents, routeEvent, and handleEvent. For more information, see "Events in Navigator 4.0".

resizeBy

Resizes the layer by the specified height and width values (in pixels).

方法源Layer
实现版本Navigator 4.0

语法

resizeBy(width, height)

参数

widthThe number of pixels by which to resize the layer horizontally.
heightThe number of pixels by which to resize the layer vertically.

描述

This does not layout any HTML contained in the layer again. Instead, the layer contents may be clipped by the new boundaries of the layer. This method has the same effect as adding width and height to clip.width and clip.height.

resizeTo

Resizes the layer to have the specified height and width values (in pixels).

方法源Layer
实现版本Navigator 4.0

描述

This does not layout any HTML contained in the layer again. Instead, the layer contents may be clipped by the new boundaries of the layer.

语法

resizeBy(width, height)

参数

widthAn integer representing the layer's width in pixels.
heightAn integer representing the layer's height in pixels.

描述

This method has the same effect setting clip.width and clip.height.

routeEvent

Passes a captured event along the normal event hierarchy.

方法源Layer
实现版本Navigator 4.0

语法

routeEvent(event)

参数

eventThe event to route.

描述

If a subobject (document or layer) is also capturing the event, the event is sent to that object. Otherwise, it is sent to its original target.

routeEvent works in tandem with captureEvents, releaseEvents, and handleEvent. For more information, see "Events in Navigator 4.0".


【目录】 【上一页】 【下一章】 【索引】

返回页面顶部

JavaScript中文手册 站长在线 整理