Javascript 如果designMode=On,则嵌入在Iframe中的Textarea将变得不可编辑

Javascript 如果designMode=On,则嵌入在Iframe中的Textarea将变得不可编辑,javascript,iframe,textarea,text-editor,Javascript,Iframe,Textarea,Text Editor,如您所见,下面我有两个函数用于将文本加粗:doRichEditCommand(),和SetToBold() 我的目标是,首先,让doRichEditCommand()在iframe中嵌入的文本区域中工作,因为它在所有主要浏览器上都能完美地工作,然后让execCommand等函数工作,因为我不确定它们在iframe中是否是跨浏览器的 对于第一个要工作的函数,我已经启用了设计模式。但是,启用该选项后,textarea将变得不可编辑 如何修改下面的代码,使我的函数能够在iframe中嵌入的textar

如您所见,下面我有两个函数用于将文本加粗:doRichEditCommand(),和SetToBold()

我的目标是,首先,让doRichEditCommand()
iframe
中嵌入的文本区域中工作,因为它在所有主要浏览器上都能完美地工作,然后让execCommand等函数工作,因为我不确定它们在iframe中是否是跨浏览器的

对于第一个要工作的函数,我已经启用了设计模式。但是,启用该选项后,textarea将变得不可编辑

如何修改下面的代码,使我的函数能够在
iframe
中嵌入的
textarea
中工作

提前感谢你的帮助

<html>
<head>
<script type="text/javascript">

function getIFrameDocument(aID){
// if contentDocument exists, W3C compliant (Mozilla)
if (document.getElementById(aID).contentDocument){
return document.getElementById(aID).contentDocument;
} else {
// IE
return document.frames[aID].document;
 }
}

function load(){
getIFrameDocument("editorWindow").designMode = "On";
}

function doRichEditCommand(aName, aArg){
getIFrameDocument('editorWindow').execCommand(aName,false, aArg);
document.getElementById('editorWindow').contentWindow.focus()
} 

function SetToBold () {
        document.execCommand ('bold', false, null);
    }
</script>
</head>
<body onload="load()">
  <iframe id="editorWindow" src="you.php"></iframe>
  <button onclick="doRichEditCommand('bold')" style="font-weight:bold;">B</button>
  <button onclick="SetToBold();">Bold</button>
</body>
</html>

函数getIFrameDocument(aID){
//如果存在contentDocument,则符合W3C标准(Mozilla)
if(document.getElementById(aID.contentDocument){
return document.getElementById(aID).contentDocument;
}否则{
//即
返回document.frames[aID].文档;
}
}
函数加载(){
getIFrameDocument(“editorWindow”).designMode=“On”;
}
函数doRichEditCommand(aName,aArg){
getIFrameDocument('editorWindow').execCommand(aName、false、aArg);
document.getElementById('editorWindow').contentWindow.focus()
} 
函数SetToBold(){
document.execCommand('bold',false,null);
}
B
大胆的
另外,我没有包括“you.php”,因为它只是必要的标记和文本区域