如何在一个HTML控件上显示一个HTML 一般情况下,一个html文件是输出到浏览器窗口中显示的,但是我想实现:把一个html文件输出到一个input类型的控件上去显示,请问高手如何实现? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我试了下面的做法,结果什么都没有显示:<input id="input1" type="text" > <frame name="NavigetionFrame" src="Navigation.htm" frameborder="1"></input> 页面上嵌入一个iframe,iframe的src就是你那html地址,就可以显示了 是在html控件上显示html代码还以如上回答的? 试一试这个:<!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=utf-8" /><title>Untitled Document</title><script language="javascript" type="text/javascript">window.onload=function(){var s=document.body.innerHTML;var b1=document.getElementById("b1");b1.value=s;}</script></head><body><form id="form1" name="form1" method="post" action=""> <label> <input name="b1" type="button" id="b1" value="" /> </label></form></body></html> 真是快死掉了,怎么都没法向iframe中写入这句:<a href="javascript:parent.location='HomePage.htm'">重定向到HomePage.htm</a>结果所写入的句子总是变成这样:<a homepage.htm="" href="javascript:parent.location=">重定向到HomePage.htm</a>大家可以亲自试验一下我的代码:<!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"><body> <input id="in1" type="" value="hello"/><div id="ad" style="position:absolute"> <iframe id="if1" src="" width="250" height="200" frameborder="0" MARGINWIDTH="0" MARGINHEIGHT="0"> </iframe> </div><script type="text/javascript"> document.getElementById("if1").contentWindow.document.write("<a href="javascript:parent.location='HomePage.htm'">重定向到HomePage.htm</a>");</script></body></html> document.getElementById("if1").contentWindow.document.write(" <a href=\"javascript:parent.location='HomePage.htm'\">重定向到HomePage.htm </a>"); 加两个\转义就行了 高手们帮忙分析一下吧!js代码浏览器兼容性问题!谢谢了 在<style>里面怎么给tr定义 onmouseover 事件? 为什么这个文字不会走动的? webqq 的效果怎么实现的? javascript的dom问题有点不大懂? 欢迎进来讨论一下javaScript对数据进行分页 window.onload调用函数的问题 简单问题,很容易拿分的,解决马上给分 求助:TEMPLATEPRINTER 出现没有权限的错误。 jq ztree,怎么根据给定的节点字符串,默认选中 函数的执行是怎么样的了 innerHtml嵌套struts2标签
<frame name="NavigetionFrame" src="Navigation.htm" frameborder="1">
</input>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" type="text/javascript">
window.onload=function(){
var s=document.body.innerHTML;
var b1=document.getElementById("b1");
b1.value=s;
}
</script>
</head><body>
<form id="form1" name="form1" method="post" action="">
<label>
<input name="b1" type="button" id="b1" value="" />
</label>
</form>
</body>
</html>
<a href="javascript:parent.location='HomePage.htm'">重定向到HomePage.htm</a>结果所写入的句子总是变成这样:
<a homepage.htm="" href="javascript:parent.location=">重定向到HomePage.htm</a>大家可以亲自试验一下我的代码:
<!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">
<body>
<input id="in1" type="" value="hello"/><div id="ad" style="position:absolute">
<iframe id="if1" src="" width="250" height="200" frameborder="0" MARGINWIDTH="0" MARGINHEIGHT="0">
</iframe>
</div><script type="text/javascript">
document.getElementById("if1").contentWindow.document.write("<a href="javascript:parent.location='HomePage.htm'">重定向到HomePage.htm</a>");
</script>
</body>
</html>
document.getElementById("if1").contentWindow.document.write(" <a href=\"javascript:parent.location='HomePage.htm'\">重定向到HomePage.htm </a>");
加两个\转义就行了