用outerHTML取得iframe内容的时候,部分代码被浏览器删除了,不知如何解决? 呵呵,来这里拿分。idContent.document.write(document.form1.content.value) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 哈哈,是<html>(包含<html>)...<body>(不包含)和</html> 写进去是innerText,读出来当然也是innerText 啦,干嘛去找outerHTML?document.form1.content.value = idContent.document.body.innerText chenzengxi(懒猫) :我的意思是:将刚才用document.write写入的html代码提取出来,我是用document.form1.content.value = idContent.document.body.outerHTML;但是丢掉了<html>(包含<html>)...<body>(不包含)和</html> emu(ston):innerText是去除html标志之后剩余的东西 <html><body><iframe id=test></iframe><BR><button onclick="testIframe()">test</button><SCRIPT LANGUAGE="JavaScript"><!--function testIframe(){test.document.body.innerText = "<html>asdfsdf</html>"alert(test.document.body.innerText)alert(test.document.body.outerHTML)}//--></SCRIPT></body></html> 但是我的iframe的状态现在为designidContent.document.designMode = "On"; 天,你到底在干什么啊?你是要描述当前iframe的完整的HTML代码?<html><body><iframe id=test></iframe><BR><button onclick="testIframe()">test</button><SCRIPT LANGUAGE="JavaScript"><!--function testIframe(){test.document.write("asdfsdfsfgsdf");html = "<html>"+test.document.body.outerHTML+"</html>"alert(html)}//--></SCRIPT></body></html> chenzengxi(懒猫):不一样,刚才是朝iframe中写入内容,现在是从iframe中提取内容 好像没什么好办法了,为什么一定要<html></html>那??document.form1.content.value = "<HTML>" +idContent.document.body.outerHTML+"</HTML>";希望没人骂我,这样也算???呵呵.... 不过,iframe只能编辑body里的内容,这样做也不会有大问题,不过你的需求也太离谱了,呵呵. 不仅仅是html啊,我的<title></title>都丢失了 那样的话你不如,在你的编辑器功能栏上,再写几个input,分别是title,head...,然后把它们拚起来。 多谢二位,我自己解决了这个问题document.form1.content.value = document.documentElement.outerHTML; documentElement PropertyRetrieves a reference to the root node of the document. 如何让for in循环只遍历对象的属性而不遍历方法 这个验证错误在哪里? 大家好,这是一个关于两个textbox之间实时传送数据的程序,请教 如何判断一个字符串中有点存在?谢谢 可编辑div的小问题 jquery的官方地址是什么? 高分求思路? 能不能说说正则表达式的规则 哪里有javascript的命令、函数方面的资料呀?初学者求教! form表单提交问题 求有效的js加密方法 我读取的html文件内容用innerHTML方式放入iframe中为什么部分内容被删除了?
提取出来,我是用
document.form1.content.value = idContent.document.body.outerHTML;
但是丢掉了<html>(包含<html>)...<body>(不包含)和</html>
<body><iframe id=test>
</iframe>
<BR>
<button onclick="testIframe()">test</button>
<SCRIPT LANGUAGE="JavaScript">
<!--
function testIframe()
{
test.document.body.innerText = "<html>asdfsdf</html>"
alert(test.document.body.innerText)
alert(test.document.body.outerHTML)
}
//-->
</SCRIPT></body>
</html>
你是要描述当前iframe的完整的HTML代码?
<html>
<body><iframe id=test>
</iframe>
<BR>
<button onclick="testIframe()">test</button>
<SCRIPT LANGUAGE="JavaScript">
<!--
function testIframe()
{
test.document.write("asdfsdfsfgsdf");
html = "<html>"+test.document.body.outerHTML+"</html>"
alert(html)
}
//-->
</SCRIPT></body>
</html>
document.form1.content.value = "<HTML>" +idContent.document.body.outerHTML+"</HTML>";
希望没人骂我,这样也算???呵呵....
document.form1.content.value = document.documentElement.outerHTML;