39,083
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<title>MyHtml.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<script type="text/javascript">
function parentFun(){
alert("父窗口的函数");
}
function parentClick(){
//document.getElementById("myFrame").childFun();
myFrame.windows.childFun();//这个方法也不可行
}
</script>
<body>
<h1>这是父窗口</h1><input type="button" value="调用子窗口的函数" onclick="parentClick()" />
<iframe id="myFrame" src="http://192.168.2.10:8080/childHtml.html" width="200" height="200"></iframe>
</body>
</html>
<html>
<head>
<title>childHtml.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<script type="text/javascript">
function childFun(){
alert("子窗口的函数");
}
function childClick(){
parent.parentFun();
/*这个方法只有在parent.html里src=本地文件夹/child.html 时才有用,child.html放到web(如上所示)上时又没用了 */ }
</script>
<body>
<h2>这是一个子窗口</h2>
<input type="button" value="调用父窗口的函数" onclick="childClick()" />
</body>
</html>