iframe页面同样需要包含那个css文件。

解决方案 »

  1.   

    大家能不能说清楚点呀我这个是在用一个<input type = "hidden" name = "edit" alue ="value(数据库取出)">然后用javascript 的IFrame.body.innerHTML=document.form1.edit.value把edit的值赋给IFrame ,Ifram其实相当于一个网页动态编辑器,从数据库取出的值有CSS样式表和一些HTML代吗
    ,HTML代码可以显示,但是就是样式表的代码传不到IFRAME里,
      真是郁闷呀
      

  2.   

    IFrame.body.innerHTML=document.form1.edit.value;
    你可以再加一句:IFrame.body.style.bgcolor='green';
      

  3.   

    you can use js to set css, too.
    obj.style.XX = YY;
      

  4.   

    Hi all 
    I am trying to use the following javascript to change all of the HTML in an iframe. The HTML is appled to the iframe and the page looks as if it had realy loaded with the inserted HTML, but the only problem is that any css files that are included don't seem to load. strTestingPageHtml = '<html><head><link rel="stylesheet" type="text/css" href="/commonCSS/menu.css" /></head><body><h1>TITLE</h1>Hello World</body></html>'
    document.getElementById('testingPageHtmlHolder').contentWindow.document.body.innerHTML = strTestingPageHtml;
      

  5.   

    IFrame.document.open("text/html","replace");
    IFrame.document.write(document.form1.edit.value);
      

  6.   

    TO:mfkfjdcwyknow that "IFrame.document.body" replay to the <body> elememt,
    and stylesheets is included by the <head> element
      

  7.   

    源代码的可以呀.是用ASP写的.也是用document.body.innerHTML,可以嵌,
    但是我用JSP将他改写就嵌不进去,郁闷.
    字符串里的<style></style><link></link>标签里的内容都嵌不进去.其它的就可以
    也就是样式表的地方嵌不进去.郁闷~~~~~
      

  8.   

    window.import_style = function(url) {
    document.write('<style type=\"text/css\">@import \"' + url + '\" ;</style>');};
      

  9.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title></title>
    <script language=javascript>
    <!--
    function displayIframe(){
    var str=document.getElementById("text1").value;
    var IFrame=document.getElementById("iframe1");
    IFrame.contentWindow.document.open("text/html","replace");
    IFrame.contentWindow.document.write(str);

    }
    //-->
    </script></head>
    <body>
    <a href="javascript:displayIframe();">显示</a><br>
    <iframe id="iframe1"></iframe>
    <form>
    <textarea id="text1" cols="60" rows="10"><html>
    <head>
    <style>
    body{background-color:black;color:yellow;}
    </style>
    </head>
    <body>
    你好!
    </body>
    </html></textarea>
    </form>
    </body>
    </html>