换个说法,我如何通过一个已打开的页面的名字得到它的句柄,然后来执行那个页面的一些函数。
如已经打开页面
test2.html
<html>
<form name=f1>
<input type=text name=txtTest value="">
</form>
</html>test1.html
<html>
<head>
<script language=javascript>
var myWin;
function btnTest_onclick(){
try{
if (myWin==null) {
myWin=window.open("test2.html");
} else{
myWin.f1.txtTest.value="I love this game !";
myWin.focus();
}
} catch(e){
myWin=null;
myWin=window.open("test2.html");
}
}
</script>
</head>
<form name=f1>
<input type=button name=btnTest onclick="btnTest_onclick();" value="测 试">
</form>
</html>
我可以用test1.html来控制test2.html
但如果test2.html不是用test1.html打开的是否也可以做类似的动作,谢谢!
如已经打开页面
test2.html
<html>
<form name=f1>
<input type=text name=txtTest value="">
</form>
</html>test1.html
<html>
<head>
<script language=javascript>
var myWin;
function btnTest_onclick(){
try{
if (myWin==null) {
myWin=window.open("test2.html");
} else{
myWin.f1.txtTest.value="I love this game !";
myWin.focus();
}
} catch(e){
myWin=null;
myWin=window.open("test2.html");
}
}
</script>
</head>
<form name=f1>
<input type=button name=btnTest onclick="btnTest_onclick();" value="测 试">
</form>
</html>
我可以用test1.html来控制test2.html
但如果test2.html不是用test1.html打开的是否也可以做类似的动作,谢谢!
我想我的问题可以用框架来处理,多谢各位!