【发布时间】:2015-01-13 23:37:00
【问题描述】:
我一直在编写文本编辑器教程以供练习,但遇到了 iframe 的问题。如果要在没有任何空格的情况下向字符发送垃圾邮件,则 iframe 将创建一个滚动条而不是破坏单词。我该如何解决这个问题,以便文本换行类似于文本区域?编辑:例如,如果有人要写“@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ "它会强制水平滚动条。我宁愿打破比 iframe 宽度更长的单词,以便它适合。
<body onLoad = "iframe()">
<h1 class="titlehead"> Title:</h1>
<form method = "post" action = "submit.php" id = "rtf">
<div class="threadpostcont">
<input type="text" name="title" class="titleinput" placeholder="Title here"></input>
<br>
<input id = "bolder" class = "textbut" type = "button" value = "Bold" onclick = "bold()">
<input class = "textbut" type = "button" value = "Italicize" onclick = "italic()">
<input class = "textbut" type = "button" value = "Underline" onclick = "underline()">
<input class = "textbut" type = "button" value = "Font Size" onclick = "fontsize()">
<input class = "textbut" type = "button" value = "Colour" onclick = "fontcolor()">
<input class = "textbut" type = "button" value = "Strike Through" onclick = "strike()">
<input class = "textbut" type = "button" value = "Link" onclick = "link()">
<input class = "textbut" type = "button" value = "Unlink" onclick = "unlink()">
<input class = "textbut" type = "button" value = "Picture" onclick = "picture()">
<input class = "textbut" type = "button" value = "List" onclick = "unlist()">
<br>
<textarea name = "textarea" id = "textarea" style = "display: none;"></textarea>
<iframe name = "editor" id = "editor" class="theframe"></iframe>
<br><br>
<input type = "button" onclick = "formsubmit()" value = "Post" id="threadsend">
</form>
</div>
</body>
还有脚本:我省略了更改为文本的功能,使代码更清晰。
function iframe(){
editor.document.designMode = 'on';}
【问题讨论】:
-
显示导致所描述问题的内容的实际示例,并指定如何将文本分成几行。 Textarea 格式非常特殊。如果您真的想在任意点打断单词而不以任何方式表明单词已被打断,您应该在问题中包含 this is。
-
在编辑中添加。是的,我希望字符串长度超过 iframe 的宽度。
标签: javascript html css iframe