参考如下代码:
<div style="height:300px; width:600px; border:1px solid #000000">
<iframe id="HtmlEditor" src="" frameborder="0" marginheight="0" marginwidth="0" style="width:100%; height:100%;">d</iframe>
<br><br>
</div>
<script type="text/javascript">
window.onload = function () {
var f = document.getElementById("HtmlEditor");
var html = '<HEAD></HEAD><BODY><div></div></BODY>';
f.contentWindow.document.open("text/html", "replace");
f.contentWindow.document.write(html);
f.contentWindow.document.close();
f.contentWindow.document.designMode = "on";
}
</script>
<div style="height:300px; width:600px; border:1px solid #000000">
<iframe id="HtmlEditor" src="" frameborder="0" marginheight="0" marginwidth="0" style="width:100%; height:100%;">d</iframe>
<br><br>
</div>
<script type="text/javascript">
window.onload = function () {
var f = document.getElementById("HtmlEditor");
var html = '<HEAD></HEAD><BODY><div></div></BODY>';
f.contentWindow.document.open("text/html", "replace");
f.contentWindow.document.write(html);
f.contentWindow.document.close();
f.contentWindow.document.designMode = "on";
}
</script>
解决方案 »
- 如何用JS清空label的值
- js怎么获取onclick(id)中id. 要有兼容性的。
- 发布一套js+jq写的客户端控件(针对ASP.NET)
- 密码框问题
- jquery操作textarea
- 高手们,如何使用 JAVASCRIPT 取得 button对象,帮帮忙啊!
- javascript函数如何不仅仅控制特定元素
- 如何判断<select>...、是否已选中?
- 急:弹出窗口被屏蔽了怎么办?
- easyui 中的datagrid 中的checkbox 如何实现点击选中,再点击取消啊?
- Javascript读取日期
- 那个高手能做出来那个酷讯选择国内就显示国内城市,国际就显示国际城市求这个AJAX局部刷新代码,急求……
<div style="height:300px; width:600px; border:1px solid #000000">
<iframe id="HtmlEditor" src="" frameborder="0" marginheight="0" marginwidth="0" style="width:100%; height:100%;"></iframe>
<br><br>
</div>
<script type="text/javascript">
window.onload = function () {
var f = document.getElementById("HtmlEditor");
var html = '<HEAD></HEAD><BODY><div></div></BODY>';
f.contentWindow.document.open("text/html", "replace");
f.contentWindow.document.write(html);
f.contentWindow.document.close();
f.contentWindow.document.body.contentEditable=true;
}
</script>
contentWindow
contentEditable
designMode