Basic operation method:
("frame_id").;
Among them, frame_id is the id of the iframe that needs to be operated on by the parent page, and action is the related operation in the iframe.
From this method, it can be seen that ("frame_id") is used to obtain the iframe's id from the parent page, and the following is the same as the general script for page elements. Let me give you a specific example to illustrate, the iframe part of the parent page reference is as follows:
<div name="region1">
<iframe onload="iframe_test()" frameborder="0" scrolling="no" width="100%" height="500" name="test_iframe" src="/" src=""></iframe>
</div>
as follows:
<%@ page language= "java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<html>
<head>
<title>test_iframe</title>
</head>
<body>
<table class="data_form" align="center">
<tr>
<th>testname</th>
<td><input name="testname" type="text" value="testname" ></td>
</tr>
<tr>
<th>description</th>
<td><input name="decription" type="text" value="testname" /></td>
</tr>
</table>
<br>
<div >
<input name="fs" type="submit" value="test" onClick="alert('test');" class="button">
</div>
</body>
</html>
The script script for operations on the iframe element in the parent page is as follows:
<script type="text/javascript"><!--
function iframe_test(){
if (("test_iframe").("testname").value=="testname")
{
alert("test successful!");
}
if(("test_iframe").("decription").value=="")
{
("test_iframe").("decription").value="description"
}
}
// --></script>
This example describes reading elements in an iframe in the parent page and modifying attributes of elements in the iframe in the parent page.
Through this example, we can see that there is no essential difference between accessing each element in an iframe in the parent page and the general access page elements. It is nothing more than that the iframe object that needs to be processed in advance in the parent page. After obtaining the iframe object, the operation is basically nothing special.
("frame_id").;
Among them, frame_id is the id of the iframe that needs to be operated on by the parent page, and action is the related operation in the iframe.
From this method, it can be seen that ("frame_id") is used to obtain the iframe's id from the parent page, and the following is the same as the general script for page elements. Let me give you a specific example to illustrate, the iframe part of the parent page reference is as follows:
Copy the codeThe code is as follows:
<div name="region1">
<iframe onload="iframe_test()" frameborder="0" scrolling="no" width="100%" height="500" name="test_iframe" src="/" src=""></iframe>
</div>
as follows:
Copy the codeThe code is as follows:
<%@ page language= "java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<html>
<head>
<title>test_iframe</title>
</head>
<body>
<table class="data_form" align="center">
<tr>
<th>testname</th>
<td><input name="testname" type="text" value="testname" ></td>
</tr>
<tr>
<th>description</th>
<td><input name="decription" type="text" value="testname" /></td>
</tr>
</table>
<br>
<div >
<input name="fs" type="submit" value="test" onClick="alert('test');" class="button">
</div>
</body>
</html>
The script script for operations on the iframe element in the parent page is as follows:
Copy the codeThe code is as follows:
<script type="text/javascript"><!--
function iframe_test(){
if (("test_iframe").("testname").value=="testname")
{
alert("test successful!");
}
if(("test_iframe").("decription").value=="")
{
("test_iframe").("decription").value="description"
}
}
// --></script>
This example describes reading elements in an iframe in the parent page and modifying attributes of elements in the iframe in the parent page.
Through this example, we can see that there is no essential difference between accessing each element in an iframe in the parent page and the general access page elements. It is nothing more than that the iframe object that needs to be processed in advance in the parent page. After obtaining the iframe object, the operation is basically nothing special.