iframe 设置HTML 我在页面中<iframe name="iniIfm" id="iniIfm" style="display:none"></iframe>我们平常给document.getElementById("iniIfm").src = decodeURIComponent(arrayUrl.iniUrl);设置iframe的内容如果我有一串HTML代码比如html><body>....</body></html>应该怎么设置呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 前提是iframe要和主页面要是同源的document.getElementById("iniIfm").contentWindow.document.body.innerHTML = "xxx"; 对象.src是设置URL文件地址,如果你把字符串加给他,那就乱套了!应该这样:主页面:<iframe id="aa" name="aa" src="aa.htm" frameborder="0" scrolling="No" width="300" height="300"></iframe><iframe id="bb" name="bb" src="bb.htm" frameborder="0" scrolling="No" width="300" height="300"></iframe><script>window.onload=function(){ document.getElementById("aa").contentWindow.document.getElementsByTagName('body')[0].innerHTML="<b>woani</b>";}</script>aa.htm:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"/></head><body><div id="wrap"> <div id="subwrap"> <div id="content"> <IMG class=picCore alt="Ceramic Structured Packings" src="1.jpg" style='width:120px;height:120px;vertical-align:top:50%' border=0> </div> </div></div> <input type="button" value="chongzai" onclick="javascript:self.location.reload();"> </body> </html>最后结果粗体我爱你将替换aa.htm里的body内容! document.getElementById("iniIfm").innerHTML = 想要的内容 window.ifr.document.write("<html><body>这个字符串换成你的字符串</body></html>"); 刚才没有注意你的iframe的名字window.iniIfm.document.write("<html><body>这个字符串换成你的字符串</body></html>"); document.getElementById("iniIfm").contentWindow.document.body.innerHTML = "xxx";或者document.getElementById("iniIfm").contentWindow.document.write("<html><body>....</body></html>"); colorbox 动态调用报错 高手给看看 javascript实现选择一个复选框对应行的复选框全部选中问题(急) 求全码——鼠标移到图片某热点。。 office2007为什么不能在网页中打开? 请问用js或其他方法如何判断浏览器是否屏蔽flash 关于一些 HTML 和 jscript 的问题,牛人进? 点击树型目录的内容打开下一级目录如何实现. 从屏幕的右下角慢慢爬上来的窗口 你是否有自己的个人网站呢? 请问:如何把select表单的内容复制到另一个select表单里~~~ ^_^ js 替换字符串中的英文字母怎么替换啊 js三级下拉菜单出错了,高手帮忙!!
document.getElementById("iniIfm").contentWindow.document.body.innerHTML = "xxx";
<iframe id="aa" name="aa" src="aa.htm" frameborder="0" scrolling="No" width="300" height="300"></iframe>
<iframe id="bb" name="bb" src="bb.htm" frameborder="0" scrolling="No" width="300" height="300"></iframe><script>
window.onload=function(){
document.getElementById("aa").contentWindow.document.getElementsByTagName('body')[0].innerHTML="<b>woani</b>";
}
</script>aa.htm:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
</head>
<body>
<div id="wrap">
<div id="subwrap">
<div id="content">
<IMG class=picCore alt="Ceramic Structured Packings" src="1.jpg" style='width:120px;height:120px;vertical-align:top:50%' border=0>
</div>
</div>
</div>
<input type="button" value="chongzai" onclick="javascript:self.location.reload();">
</body>
</html>
最后结果粗体我爱你将替换aa.htm里的body内容!
或者document.getElementById("iniIfm").contentWindow.document.write("<html><body>....</body></html>");