大家能不能说清楚点呀我这个是在用一个<input type = "hidden" name = "edit" alue ="value(数据库取出)">然后用javascript 的IFrame.body.innerHTML=document.form1.edit.value把edit的值赋给IFrame ,Ifram其实相当于一个网页动态编辑器,从数据库取出的值有CSS样式表和一些HTML代吗 ,HTML代码可以显示,但是就是样式表的代码传不到IFRAME里, 真是郁闷呀
you can use js to set css, too. obj.style.XX = YY;
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;
<!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);
,HTML代码可以显示,但是就是样式表的代码传不到IFRAME里,
真是郁闷呀
你可以再加一句:IFrame.body.style.bgcolor='green';
obj.style.XX = YY;
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;
IFrame.document.write(document.form1.edit.value);
and stylesheets is included by the <head> element
但是我用JSP将他改写就嵌不进去,郁闷.
字符串里的<style></style><link></link>标签里的内容都嵌不进去.其它的就可以
也就是样式表的地方嵌不进去.郁闷~~~~~
document.write('<style type=\"text/css\">@import \"' + url + '\" ;</style>');};
<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>