呼叫iframe中的按鈕點選
阿新 • • 發佈:2019-01-02
index.html
<html>
<head><meta http-equiv="content-type" content="text/html;charset=utf-8">
<script type="text/javascript">
function callChild(){
//myFrame.window.say();
myFrame.window.document.getElementById("button").click();
//var x= myFrame.window.document.getElementById("myen").innerHTML="kkkkk";//可以用
}
</script></head>
<body>
<input id="button" type="button" value="呼叫child.html中按鈕的點選" onclick="callChild()"/><br><iframe name="myFrame"
src="child.html" width="800"></iframe>
</body>
</html>
child.html
<html>
<head><meta http-equiv ="content-type" content="text/html;charset=utf-8"></head>
<script type="text/javascript">
function inenword(){
var x=document.getElementById("enword").value;
document.getElementById("myen").innerHTML=x;
}
</script>
<h1>查詢單詞</h1>
請輸入英文單詞:<input type="text" name ="enword" id="enword">
<input type="button" id="button" value="查詢" onclick="inenword()">
<br>您要查詢的英文是:<span id="myen"></span>
</html>