iframe里必须和外面的是同一个域才行,否则会报拒绝访问

解决方案 »

  1.   

    不是通过设置src,使iframe显示别的网页文件,而是显示以字符串变量形式存储的数据。
      

  2.   

    那你为什么要用 iframe 呢?
      

  3.   

    <iframe id="iframe" width="300" height="200"></iframe>
    <script language="javascript">
    <!--
    var str = "<html>\
    <body>\
    this is test\
    <input type='text' value='textbox'/>\
    <input type='button' value='提交'/>\
    <p style='font-weight:bold'>bold text</p>\
    <img src='http://community.csdn.net/images/CSDN_logo.GIF'/>\
    </body>\
    </html>";
    var d = window.frames[0];
    d.document.write(str);//-->
    </script>
      

  4.   

    iframe就是用来显示完整html代码的,如果不是完整htnl代码,可供选择的元素就一大堆了,比如使用div