iframe.document.location.reload;
iframe.document.write(......);

解决方案 »

  1.   

    emu(ston) 
    你好。
    谢谢你回答。
    主  题:  如何象iframe中插入一段已经存的html? 
    作  者:  icerose (冰玫瑰)  我不知是否因为的水平太差没看明白你的程序,或者是我问题表达的不清。
    我是意思是在一个window中有一个iframe,此时为空。在iframe之外和两个tabel两个button.
    当点击第一个button时,在先清空iframe的内容,然后将第一个table插入iframe中
    当点击第二个button时,在先清空iframe的内容,然后将第二个table插入iframe中iframe.document.write(......);我想参数应是一段超文本吧。我想问是不可以传入
    表格的id之类东西。可以一下子写入一大段内容。谢谢。
      

  2.   

    呵呵,iframeName.innerHTML=" "
     表格啊,呵呵,自己做啊"<table></table>................"
    多运用一下JAVASCRIPT设置一下就可以了
      

  3.   

    ifram 有 innerHTML 属性吗?我的办法是:
    在 iframe 的页面中定义一个 div,比如叫 divX;或者在 window.onload 时用 document.write 往 iframe 中写一个 div;
    在主窗口中定义两个 div,div1 包含 table1;div2 包含 table2;
    button1.onclick: iframe1.divX.innerHTML = div1.innerHTML
    button2.onclick: ...
      

  4.   

    这么干 :
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title></title>
    </head>
    <body>
    <iframe src="Noname2.html" id=test>
    </iframe>
    <BR>
    <button onclick="show1()">test</button>
    &nbsp;&nbsp;&nbsp;
    <button onclick="show2()">test</button>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function show1()
    {
    test.document.location.reload();
    test.document.write("<TABLE>");
    test.document.write("<TR>");
    test.document.write(" <TD>abc</TD>");
    test.document.write(" <TD>dev</TD>");
    test.document.write("</TR>");
    test.document.write("<TR>");
    test.document.write(" <TD>ghi</TD>");
    test.document.write(" <TD>jkl</TD>");
    test.document.write("</TR>");
    test.document.write("</TABLE>");}
    function show2()
    {
    test.document.location.reload();
    test.document.write("<TABLE>");
    test.document.write("<TR>");
    test.document.write(" <TD>123</TD>");
    test.document.write(" <TD>456</TD>");
    test.document.write("</TR>");
    test.document.write("<TR>");
    test.document.write(" <TD>789</TD>");
    test.document.write(" <TD>000</TD>");
    test.document.write("</TR>");
    test.document.write("</TABLE>");}
    //-->
    </SCRIPT>
    </body>
    </html>
      

  5.   

    要是用innerHTML可以这么写:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title></title>
    </head>
    <body>
    <iframe src="Noname2.html" id=test>
    </iframe>
    <BR>
    <button onclick="show1()">test1</button>
    &nbsp;&nbsp;&nbsp;
    <button onclick="show2()">test2</button>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function show1()
    {
    test.document.body.innerHTML = "";
    test.document.write("<TABLE>");
    test.document.write("<TR>");
    test.document.write(" <TD>abc</TD>");
    test.document.write(" <TD>dev</TD>");
    test.document.write("</TR>");
    test.document.write("<TR>");
    test.document.write(" <TD>ghi</TD>");
    test.document.write(" <TD>jkl</TD>");
    test.document.write("</TR>");
    test.document.write("</TABLE>");}
    function show2()
    {
    test.document.body.innerHTML = "";
    test.document.write("<TABLE>");
    test.document.write("<TR>");
    test.document.write(" <TD>123</TD>");
    test.document.write(" <TD>456</TD>");
    test.document.write("</TR>");
    test.document.write("<TR>");
    test.document.write(" <TD>789</TD>");
    test.document.write(" <TD>000</TD>");
    test.document.write("</TR>");
    test.document.write("</TABLE>");}
    //-->
    </SCRIPT>
    </body>
    </html>
    但是页面就不能有默认的内容了
      

  6.   

    要是table已经存在的话可以这么写:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title></title>
    </head>
    <body>
    <iframe src="Noname2.html" id=test>
    </iframe>
    <BR>
    <TABLE>
    <TR>
    <TD>abc</TD>
    <TD>def</TD>
    </TR>
    <TR>
    <TD>ghi</TD>
    <TD>jkl</TD>
    </TR>
    </TABLE>
    <BR><BR>
    <TABLE>
    <TR>
    <TD>123</TD>
    <TD>456</TD>
    </TR>
    <TR>
    <TD>789</TD>
    <TD>000</TD>
    </TR>
    </TABLE>
    <BR>
    <BR>
    <button onclick="show1()">test1</button>
    &nbsp;&nbsp;&nbsp;
    <button onclick="show2()">test2</button>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function show1()
    {
    //把当前页面第一个表格写到iframe里面
    test.document.body.innerHTML = document.all.tags("table")[0].outerHTML
    }
    function show2()
    {
    //把当前页面第二个表格写到iframe里面
    test.document.body.innerHTML = document.all.tags("table")[1].outerHTML
    }
    //-->
    </SCRIPT>
    </body>
    </html>
    当然也可以给每个table对象一个id号来引用而不是通过all来引用:<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title></title>
    </head>
    <body>
    <iframe src="Noname2.html" id=test>
    </iframe>
    <BR>
    <TABLE id=table1>
    <TR>
    <TD>abc</TD>
    <TD>def</TD>
    </TR>
    <TR>
    <TD>ghi</TD>
    <TD>jkl</TD>
    </TR>
    </TABLE>
    <BR><BR>
    <TABLE id=table2>
    <TR>
    <TD>123</TD>
    <TD>456</TD>
    </TR>
    <TR>
    <TD>789</TD>
    <TD>000</TD>
    </TR>
    </TABLE>
    <BR>
    <BR>
    <button onclick="show1()">test1</button>
    &nbsp;&nbsp;&nbsp;
    <button onclick="show2()">test2</button>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function show1()
    {
    //把当前页面第一个表格写到iframe里面
    test.document.body.innerHTML = table1.outerHTML
    }
    function show2()
    {
    //把当前页面第二个表格写到iframe里面
    test.document.body.innerHTML = table2.outerHTML
    }
    //-->
    </SCRIPT>
    </body>
    </html>
      

  7.   

    谢谢大家的热情帮助。
    andysern(风亦),呵,呵.如果我能提前知道表格是什么样子的,我还用通过函数动态的插入吗?直接写入不就行了?:-)
    lonelyghost() 你的方法,让我想到如何在同一网页内插入的东东的办法了,谢谢
    emu(ston) :太谢谢了。