Get the document element in the IFRAME with a centralized approach:
1. getElementById () method and Contentwindow property:
window.onload=function/* must wait for page load to finish * /
document.getElementById ("ID of iframe"). ContentWindow.document.getElementById ("ID of element")
document.getElementById ("ID of iframe"). Contentdocument.getelementbyid ("ID of Element") }
Note: the above. Contentdocument ( cannot be used in IE, because IE does not exist in this property) is equivalent to. contentwindow.document!
2. Window. Frames property of the object
window.onload=function/* must wait for page load to finish */ window.frames[" Index or IFRAME Name property value "].document.getelementbyid (ID of element")}
The Window.frames property refers to a class array object and can be indexed by a number or form name.
WINDOW.FRAMES[0]//The first subform of a window
window.frames["The name attribute value of the iframe"]//window.frames["F1"] or WINDOW.FRAMES.F1
Note: The element in the frames[] array is the Window object, not the <iframe> element
3. The Name property value of the IFRAME
window.onload=function/* must wait for the page to load after the end of the */ iframe's Name property value. document.getElementById ("Element ID") /* The name of the form refers to the Window object in the form * /
}
Note: You can replace FRAMES.F1 with the name "F1" of the form.
Add:
Gets the form of the IFRAME: document.getElementById ("ID of the IFRAME"). Contentwindow = window.frames["index or the Name property value of the iframe"] = The property value of the name of the IFRAME
Get the elements of an iframe and manipulate them