大家帮我看看为什么这段代码在firefox下不能运行??

brucenan999 2007-07-29 10:27:13
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Windows (vers 13 May 2007), see www.w3.org" />
<meta http-equiv="Content-Type" content=
"text/html; charset=us-ascii" />

<title>title</title>
<script language="javascript" type="text/javascript">

function Bold()
{
window.frames['edit'].document .selection.createRange().execCommand("Bold",false,null);
}

function TOHTML()
{
window.document.getElementById('preview').innerText =window.frames['edit'].document.body.innerHTML;

}

function FromHTML()
{
if (window.document.getElementById('preview').innerText !='')
{
window.frames['edit'].document.body .innerText = '';
window.frames['edit'].document.write(window.document.getElementById('preview').innerText);
}
}



</script>
</head>

<body>
<form>
<iframe src="" name="edit" id="edit" frameborder="1" width=
"495" height="295" marginWidth="0" marginHeight="0"></iframe>
<textarea src="" name="preview" id="preview" width="800"
height="400" rows="7" cols="69">
</textarea> <script language="javascript" type="text/javascript">

window.frames["edit"].document.designMode="On";
window.frames["edit"].document.contentEditable = true;

</script>
<button onclick="Bold();">Bold</button>
<button onclick="TOHTML();">Page To HTML </button>
<button onclick="FromHTML();">HTML To Page</button>
</form>
</body>
</html>
=====================================================================
是一个编辑器,在IE下可以运行,但是在Firefox下运行总是有问题,不知道是怎么回事?

哪位高手帮忙看一下?谢谢.

...全文
184 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
fffddd 2007-08-02
  • 打赏
  • 举报
回复
建议你下载个所有浏览器兼容的编辑器,网上有现成这样的

孟兄给个地址?
brucenan999 2007-08-01
  • 打赏
  • 举报
回复
没有人回答吗?
brucenan999 2007-07-30
  • 打赏
  • 举报
回复
参考了别人的代码,设置黑体可以用了
editor.contentWindow.focus();
var Range;
if(ie)
{
Range=editor.contentWindow.document.selection.createRange();
Range.execCommand("bold",false,false);
}
else
{
//Range=editor.contentWindow.document.getSelection ? editor.contentWindow. document.getSelection() : window.getSelection();
editor.contentWindow.document.execCommand("bold",false,false);
}
================================================================================
但是显示HTML到TEXTAREA的还是不能用...
window.document.getElementById('preview').text =window.frames['edit'].document.body.innerHTML;
不知道为什么window.document.getElementById('preview').text赋值会没有效果..
brucenan999 2007-07-29
  • 打赏
  • 举报
回复
fckeditor下了,但是功能太多,没分析出头绪啊. 只是要做个简单的编辑器,所以不想用那么复杂的.
孟子E章 2007-07-29
  • 打赏
  • 举报
回复
建议你下载个所有浏览器兼容的编辑器,网上有现成这样的
梅雪香 2007-07-29
  • 打赏
  • 举报
回复
FF下这个方法吗?execCommand("Bold",false,null);
FF下是不支持innerText的