如何打破iframe中的单词

时间:2015-01-13 06:17:56

标签: javascript html css iframe

我一直致力于练习的文本编辑器教程,并遇到了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';}

1 个答案:

答案 0 :(得分:-1)

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

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