example.htm
<Iframe src="test.htm" id="t" width="250" height="200" scrolling="no" frameborder="0"></iframe>
<script>
function fun(){
t.document.all.myH1.innerText="hello,my dear,fff";
}
</script>
<input type="button" value="aaa" onClick="fun()">

解决方案 »

  1.   

    为什么必须要用一个按钮来触发呢,如果我不要这个按钮
    <Iframe src="test.htm" id="t" width="250" height="200" scrolling="no" frameborder="0"></iframe>
    <script>
    //function fun(){
    t.document.all.myH1.innerText="hello,my dear,fff";
    //}
    </script>
    <input type="button" value="aaa" onClick="fun()">
    程序就会报我那个错,这是为什么,我现在不能要按钮来触发它,应该怎么做
      

  2.   

    你打开页面.最先加载的就是脚本.当加载脚本的时候t.document.all.myH1这个肯定出错!!
      

  3.   

    页面打开最先加载的是脚本,这句话不对吧
    <script>tt.value="123";</script>
    <input type="text" name="tt">
    这段代码肯定错,改成下面的就对了,
    <input type="text" name="tt">
    <script>tt.value="123";</script>
    但这样一来,就不象你说的是先加载脚本吧,应该是按顺序加载