我有一個iFrame來創建消息。但是,當我在輸入iFrame時按Enter鍵時,它會創建另一個div,但是,我希望它創建一個<br/>
。我嘗試使用execCommand insertBrOnReturn,但我沒有得到它的工作。有任何想法嗎?提前致謝!iFrame中止輸入密鑰
中的jsfiddle在計算器並沒有真正的工作,但我有一個現有的「Craz1k0ek/d869w67b /」默認jsfiddle.net
function iFrameOn() {
richTextField.document.designMode = 'On';
richTextField.document.body.style.fontFamily = 'Open Sans,Helvetica Neue,Helvetica,Arial,sans-serif';
}
function iBold() {
richTextField.document.execCommand('bold', false, null);
}
function iUnderline() {
richTextField.document.execCommand('underline', false, null);
}
function iItalic() {
richTextField.document.execCommand('italic', false, null);
}
function submit_form() {
var theForm = document.getElementById("myForm");
theForm.elements["myTextArea"].value = window.frames['richTextField'].document.body.innerHTML;
theForm.submit();
}
<body onload="iFrameOn()">
<form action="" name="myForm" id="myForm" method="post">
<p>
Title
<input name="title" id="title" type="text" size="80" maxlength="80">
</p>
<div id="wysiwyg_cp" style="padding:8px; width:700px;">
<input type="button" onClick="iBold()" value="B">
<input type="button" onClick="iUnderline()" value="U">
<input type="button" onClick="iItalic()" value="I">
</div>
<textarea style="display:none;" name="myTextArea" id="myTextArea" cols="100" rows="14"></textarea>
<iframe name="richTextField" id="richTextField" style="border:#000 1px solid; width:700px; height:300px;"></iframe>
<input name="myBtn" type="button" value="Submit Data" onClick="javascript:submit_form();">
</form>
</body>