Basic methods of operation:
Document.frames ("frame_id"). Document.action;
Where the frame_id is the id,action of the IFRAME that the parent page needs to operate is the related operation in the IFRAME.
From this approach, you can see that document.frames ("frame_id") is used to get the ID of the IFRAME from the parent page, and the following document.action is the same as a typical script for page element operations, for example, Where the parent page references the IFRAME section as follows:
Copy Code code as follows:
<div id= "Region1" name= "Region1" >
<iframe onload= "Iframe_test ()" frameborder= "0" scrolling= "no" width= "100%" "height=" "Name=" Test_iframe "id=" Test_iframe "src="/testiframe.jsp "src=" testiframe.jsp "></iframe>
</div>
Testiframe.jsp is as follows:
Copy Code code as follows:
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" Utf-8 "%>
<title>test_iframe</title>
<body>
<table class= "data_form" align= "Center" >
<tr>
<th>testname</th>
<td><input name= "testname" type= "text" id= "testname" value= "TestName" ></td>
</tr>
<tr>
<th>description</th>
<td><input name= "decription" type= "text" id= "decription" value= "TestName"/></td>
</tr>
</table>
<br>
<div >
<input name= "FS" type= "Submit" id= "FS" value= "Test" onclick= "alert (' Test ');" class= button ">
</div>
</body>
The script scripts for the actions of the IFRAME elements in the parent page are as follows:
Copy Code code as follows:
<script type= "Text/javascript" ><!--
function Iframe_test () {
if (Document.frames ("Test_iframe"). document.getElementById ("TestName"). value== "TestName")
{
Alert ("Test successful!");
}
if (Document.frames ("Test_iframe"). document.getElementById ("Decription"). value== "")
{
Document.frames ("Test_iframe"). document.getElementById ("Decription"). Value= "description"
}
}
--></script>
This example describes the properties of reading elements in an IFRAME in the parent page and modifying the elements in the IFRAME in the parent page.
Through this example, we can see that in the parent page to access the elements of the IFRAME and the general access page elements are not fundamentally different, nothing more than the need to obtain in advance in the parent page to deal with the IFrame object, in the acquisition of the IFrame object, its operation is basically no special place.