怎样让iframe调用父页面的javascript函数?
parent.htm代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>TestIFrame</title>
<script language="javaScript">
function testfunc()
{
alert("This is a test!");
}
</SCRIPT>
</head>
<body>
<table width="778" border="0" cellspacing="0" cellpadding="0" align="center" class="bg_b">
<tr>
<td width="68" class="bg_t2"> </td>
<td width="280" valign=top> <br>
</td>
<td width="20"> </td>
<td width="190" valign="top"><br>
<iframe frameborder=0 id=newsbody name=newsbody2 scrolling=no src="iframe.htm" ></iframe>
</td>
<td width="11"></td>
<td valign="top" class="bg_a" WIDTH=210><br>
</td>
</tr>
</table>
</body>
</html>
------------------------
iframe.htm代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>
<body>
<input type="button" value="Test" name="btntest" οnclick="parent.testfunc();">
</body>
</html>
怎样在父页面里调用iframe里的javascript函数,不知能否这样调用。
document.frames("iframeName").functionName()
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/antony1029/archive/2009/08/18/4460366.aspx