日期:2014-05-16  浏览次数:20326 次

框架中传递javascript函数的问题
HTML code
<html>
<head>
<title>TestFrame</title>
</head>
       <frameset rows="50%,50%">
            <frame src="main.asp" name="main">
            <frame src="send.asp" name="send">
       </frameset>
</html>


HTML code

<html>
<body>
<script language="javascript">
       function testframe(){
              document.write("TestFrame!");
       }
</script>
</body>
</html>


HTML code

<html>
<body>
    <input type="button" name="test1"  value=" 提 交 " onClick="parent.main.testframe()">
</body>
</html>


以上是我测试框架中传递Javascript函数的代码,第一次点提交就没问题,但第2次继续点这按钮时弹出"对象不支持此属性或方法"的问题,请问是哪里出错了

------解决方案--------------------
testframe中用的是document.write("TestFrame!");
第一次执行後,main中的页面被重写了,testframe()不存在了
function testframe(){
alert("TestFrame!");
}
试试看