VaR detialiframe = Document. All ("detialiframe ");
IFRAME is obtained from the document, that is, it appears as a sub-object of the document. Although it is a document object, it has its own event because it is an independent page, has its own window object (contentWindow); window. detialiframe or window. frames (detialiframe) will directly obtain the window object of IFRAME
IFRAME
The IFRAME element is the document in the document.
Window object
The browser will create a corresponding window object when it opens an HTML document. However, if a document defines one or more frameworks (including one or more frames or IFRAME tags), the browser creates a window object for the original document, create an additional window object for each frame. These additional objects are subwindows of the original window and may be affected by events in the original window. For example, closing the original window will close all subwindows. To create a new window (and corresponding window objects), you can use methods like open, showmodaldialog, and showmodelessdialog.
ContentWindow
The contentWindow attribute refers to the window object where the specified frame or IFRAME is located.
In ie, the contentWindow attribute of IFRAME or frame can be omitted. However, to edit an IFRAME object in Firefox, you must specify the contentWindow attribute.
Function enableedit ()
{
VaR editor;
Editor = Document. getelementbyid ("htmledit"). contentWindow;
// Make it editable for IE browser
Editor.doc ument. designMode = 'on ';
Editor.doc ument. contenteditable = true;
// For compatible with Firefox, it shoshould open and write something to make it work
Editor.doc ument. open ();
Editor.doc ument. writeln ('<HTML>
Editor.doc ument. writeln ('<style> body {Background: white; font-size: 9pt; margin: 2px; padding: 0px;} </style> ');
Editor.doc ument. writeln ('
Editor.doc ument. Close ();
}
<IFRAME id = "htmledit" marginheight = "1" marginwidth = "1" width = "100%" Height = "312">
</Iframe>
<HTML>
<Body>
<SCRIPT>
VaR IFR = Document. createelement ("iframe ");
Document. Body. appendchild (IFR );
VaR ifrdoc = ifr.content?#doc ument;
VaR S = fixinghtb. innerhtml; // save it before entering editable Mode
Ifrdoc. designMode = "on"; // The document enters the Editable mode.
Ifrdoc. open (); // open the stream
Ifrdoc. Write (s );
Ifrdoc. Close (); // close the stream
Ifrdoc. designMode = "off"; // The document enters the non-editable mode.
</SCRIPT>
</Body>
</Html>