nsIDOMNSHTMLDocument 编辑
dom/interfaces/html/nsIDOMNSHTMLDocument.idl
Scriptable 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
Attribute | Type | Description |
alinkColor | DOMString | Same as body.aLink |
bgColor | DOMString | Same as body.bgColor |
compatMode | DOMString | Returns "BackCompat" if the document is in Quirks mode or "CSS1Compat" if the document is in Full Standards or Almost Standards mode. Read only. |
designMode | DOMString | Set to "on" or "off" to enable or disable editing for the entire document at once. Roughly equivalent to body.contentEditable |
domain | DOMString | Initially 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. |
embeds |
| Equivalent to getElementsByTagName("embed") Read only. |
fgColor | DOMString | Same as body.text |
head |
| Returns 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. |
height | long | The height of the body element. Read only. Obsolete since Gecko 6.0 |
linkColor | DOMString | Same as body.link |
plugins |
| Same as embeds for compatibility with Netscape 4.x Read only. |
vlinkColor | DOMString | Same as body.vLink |
width | long | The 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:
nsHTMLDocument
class:content/html/document/src/nsHTMLDocument.h
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论