nsIDOMNSHTMLDocument 编辑

dom/interfaces/html/nsIDOMNSHTMLDocument.idlScriptable This interface defines methods and properties supported by Gecko on the document object that are not part of DOM Level 2. Inherits from: nsISupports Last changed in Gecko 6.0 (Firefox 6.0 / Thunderbird 6.0 / SeaMonkey 2.3)

Method overview

void captureEvents(in long eventFlags);
void clear();
boolean execCommand(in DOMString commandID, in boolean doShowUI, in DOMString value);
boolean execCommandShowHelp(in DOMString commandID); Obsolete since Gecko 14.0
DOMString getSelection();
nsIDOMDocument open(in ACString aContentType, in boolean aReplace);
boolean queryCommandEnabled(in DOMString commandID);
boolean queryCommandIndeterm(in DOMString commandID);
boolean queryCommandState(in DOMString commandID);
boolean queryCommandSupported(in DOMString commandID);
DOMString queryCommandText(in DOMString commandID); Obsolete since Gecko 14.0
DOMString queryCommandValue(in DOMString commandID);
void releaseEvents(in long eventFlags);
void routeEvent(in nsIDOMEvent evt);
void write(); Obsolete since Gecko 2.0
void writeln(); Obsolete since Gecko 2.0

Attributes

AttributeTypeDescription
alinkColorDOMStringSame as body.aLink
bgColorDOMStringSame as body.bgColor
compatModeDOMStringReturns "BackCompat" if the document is in Quirks mode or "CSS1Compat" if the document is in Full Standards or Almost Standards mode. Read only.
designModeDOMStringSet to "on" or "off" to enable or disable editing for the entire document at once. Roughly equivalent to body.contentEditable
domainDOMStringInitially the host name of the document's URL, but may be changed to the parent (but not top-level) domain in order to facilitate data exchange between documents from different sites in the same domain.
embedsnsIDOMHTMLCollectionEquivalent to getElementsByTagName("embed") Read only.
fgColorDOMStringSame as body.text
headnsIDOMHTMLHeadElementReturns the first child element of the HTML element that is a HEAD element, or null if there is no HTML or HEAD element. Read only.
heightlongThe height of the body element. Read only. Obsolete since Gecko 6.0
linkColorDOMStringSame as body.link
pluginsnsIDOMHTMLCollectionSame as embeds for compatibility with Netscape 4.x Read only.
vlinkColorDOMStringSame as body.vLink
widthlongThe width of the body element. Read only. Obsolete since Gecko 6.0

Methods

captureEvents()

Provided for compatibility with Netscape 4.x, but does not actually do anything.

void captureEvents(
  in long eventFlags
);
Parameters
eventFlags
 

clear()

Used to reset a document to blank, but deprecated since Gecko 1.0 and provided for compatibility with Netscape 4.x; use open() and close() instead.

void clear();
Parameters

None.

execCommand()

boolean execCommand(
  in DOMString commandID,
  in boolean doShowUI,
  in DOMString value
);
Parameters
commandID
The name of the command to execute. See Rich-Text Editing in Mozilla for a list of supported commands.
doShowUI
This is not implemented in Gecko.
value
Some commands require an argument. You can pass null for those commands that do not need an argument.
Return value

true if the command was recognized, false otherwise.

execCommandShowHelp()

Obsolete since Gecko 14.0 (Firefox 14.0 / Thunderbird 14.0 / SeaMonkey 2.11)

This method never did anything but throw an exception, and was removed entirely in Gecko 14.0 (Firefox 14.0 / Thunderbird 14.0 / SeaMonkey 2.11).

boolean execCommandShowHelp(
  in DOMString commandID
);
Parameters
commandID
The name of the command.
Return value

This method is not supported and always throws an exception.

getSelection()

DOMString getSelection();
Parameters

None.

Return value

The text of the current selection, the same as window.getSelection.toString().

open()

nsIDOMDocument open(
  in ACString aContentType,
  in boolean aReplace
);
Parameters
aContentType
The content type of the new document. If the type is not supported by the HTML content sink, trying to write to the document will probably throw.
aReplace
Whether the document should replace the existing document in session history.
Return value

The new document.

queryCommandEnabled()

boolean queryCommandEnabled(
  in DOMString commandID
);
Parameters
commandID
The name of the command to query.
Return value

Returns true if the command is supported and enabled, false otherwise.

queryCommandIndeterm()

boolean queryCommandIndeterm(
  in DOMString commandID
);
Parameters
commandID
The name of the command to query.
Return value

For stateful commands, returns true if the command is in an indeterminate state, false otherwise. For instance, if there is a selection and part of the selected text is bold, then then bold command is in an indeterminate state.

queryCommandState()

boolean queryCommandState(
  in DOMString commandID
);
Parameters
commandID
The name of the command to query.
Return value

For stateful commands, returns true if the command has is active, false otherwise.

queryCommandSupported()

boolean queryCommandSupported(
  in DOMString commandID
);
Parameters
commandID
The name of the command to query.
Return value

Returns true if the command is supported on the current range, false otherwise.

queryCommandText()

Obsolete since Gecko 14.0 (Firefox 14.0 / Thunderbird 14.0 / SeaMonkey 2.11)

This method never did anything but throw an exception, and was removed entirely in Gecko 14.0 (Firefox 14.0 / Thunderbird 14.0 / SeaMonkey 2.11).

DOMString queryCommandText(
  in DOMString commandID
);
Parameters
commandID
The name of the command to query.
Return value

This method is not supported and always throws an exception.

queryCommandValue()

DOMString queryCommandValue(
  in DOMString commandID
);
Parameters
commandID
The name of the command to query.
Return value

The value of the command. For the gethtml command, the current selection is returned as an HTML source fragment.

releaseEvents()

Provided for compatibility with Netscape 4.x, but does not actually do anything.

void releaseEvents(
  in long eventFlags
);
Parameters
eventFlags
 

routeEvent()

Provided for compatibility with Netscape 4.x, but does not actually do anything.

void routeEvent(
  in nsIDOMEvent evt
);
Parameters
evt
 

write()

Obsolete since Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)
void write(
  [optional] in DOMString text
);
Parameters
text
The string to write to the document.

writeln()

Obsolete since Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)
void writeln(
  [optional] in DOMString text
);
Parameters
text
The string to write to the document. A newline is automatically appended.

Implemented by

Classes that implement this interface:

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:106 次

字数:15208

最后编辑:8年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文