如何在 iframe 中断开单词

How to break words in an iframe

本文关键字:断开 单词 中断 iframe      更新时间:2023-09-26

我一直在做一个文本编辑器教程来练习,遇到了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';}

您可以尝试使用 CSS3 word-break属性。

http://www.w3schools.com/cssref/css3_pr_word-break.asp