如何在浏览器中创建可写的HTML文档?

时间:2022-10-30 13:30:18

Lest my question is not clear; I don't mean dynamically replacing <p> nodes with <textarea>. I mean editing each and all text directly - including headers, text in <div> and <span> and yes editing tables. I know this is possible in IE and I have a script which switches between editable and back which works in IE, but that doesn't work in Firefox. Is there any way to make it work in FF?

以免我的问题不清楚;我不是指用

节点。我的意思是直接编辑每个文本 - 包括标题,

中的文本以及是编辑表格。我知道在IE中这是可能的,我有一个在可编辑和后退之间切换的脚本在IE中工作,但这在Firefox中不起作用。有没有办法让它在FF中运行?

P.S. The script for IE I got from JavaScript Bible Gold Edition by Danny Goodman, 2001

附:我从2001年的Danny Goodman的JavaScript Bible Gold Edition获得的IE脚本

2 个解决方案

#1


In firefox > 3 you can use contentEditable for html elements I understood. A tag looks like this:

在firefox> 3中,您可以将contentEditable用于我理解的html元素。标签看起来像这样:

<div id="myEditableDiv" contentEditable="true">click here to edit ...</div>

you can control the editing process with 'execCommand' (see: msdn for command identifiers)

您可以使用'execCommand'控制编辑过程(请参阅:命名标识符的msdn)

#2


Firebug Extension for Firefox pretty much allows you to edit anything.

Firebug Extension for Firefox几乎可以让你编辑任何东西。

#1


In firefox > 3 you can use contentEditable for html elements I understood. A tag looks like this:

在firefox> 3中,您可以将contentEditable用于我理解的html元素。标签看起来像这样:

<div id="myEditableDiv" contentEditable="true">click here to edit ...</div>

you can control the editing process with 'execCommand' (see: msdn for command identifiers)

您可以使用'execCommand'控制编辑过程(请参阅:命名标识符的msdn)

#2


Firebug Extension for Firefox pretty much allows you to edit anything.

Firebug Extension for Firefox几乎可以让你编辑任何东西。