简体   繁体   English

RTF编辑器无法在Firefox上运行

[英]rich text editor not working on firefox

<html>
<head>
<title>Rich Text Editor</title>
</head>
<body onLoad="def()"><center>
<div style="width:500px; text-align:left; margin-bottom:10px ">
<input type="button" id="bold" style="height:21px; width:21px; font-weight:bold;" value="B" onClick="fontEdit('bold')" />
<input type="button" id="italic" style="height:21px; width:21px; font-style:italic;" value="I" onClick="fontEdit('italic')" />
<input type="button" id="underline" style="height:21px; width:21px; text-decoration:underline;" value="U" onClick="fontEdit('underline')" /> | 
<input type="button" style="height:21px; width:21px;"value="L" onClick="fontEdit('justifyleft')" title="align left" />
<input type="button" style="height:21px; width:21px;"value="C" onClick="fontEdit('justifycenter')" title="center" />
<input type="button" style="height:21px; width:21px;"value="R" onClick="fontEdit('justifyright')" title="align right" /> | 
<select id="fonts" onChange="fontEdit('fontname',this[this.selectedIndex].value)">
<option value="Arial">Arial</option>
<option value="Comic Sans MS">Comic Sans MS</option>
<option value="Courier New">Courier New</option>
<option value="Monotype Corsiva">Monotype</option>
<option value="Tahoma">Tahoma</option>
<option value="Times">Times</option>
</select>
<select id="size" onChange="fontEdit('fontsize',this[this.selectedIndex].value)">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<select id="color" onChange="fontEdit('ForeColor',this[this.selectedIndex].value)">
<option value="black">-</option>
<option style="color:red;" value="red">-</option>
<option style="color:blue;" value="blue">-</option>
<option style="color:green;" value="green">-</option>
<option style="color:pink;" value="pink">-</option>
</select> | 
<input type="button" style="height:21px; width:21px;"value="1" onClick="fontEdit('insertorderedlist')" title="Numbered List" />
<input type="button" style="height:21px; width:21px;"value="?" onClick="fontEdit('insertunorderedlist')" title="Bullets List" />
<input type="button" style="height:21px; width:21px;"value="?" onClick="fontEdit('outdent')" title="Outdent" />
<input type="button" style="height:21px; width:21px;"value="?" onClick="fontEdit('indent')" title="Indent" />
</div>
<iframe id="textEditor" style="width:500px; height:170px;">
</iframe>
</center>
<script type="text/javascript">
<!--
textEditor.document.designMode="on";
textEditor.document.open();
textEditor.document.write('<head><style type="text/css">body{ font-family:arial; font-size:13px;}</style></head>');
textEditor.document.close();
function def()
{
document.getElementById("fonts").selectedIndex=0;
document.getElementById("size").selectedIndex=1;
document.getElementById("color").selectedIndex=0;
}
function fontEdit(x,y)
{
textEditor.document.execCommand(x,"",y);
textEditor.focus();
}
-->
</script>
</body>
</html>

i browsed these codes online. 我在线浏览了这些代码。 yet i can't make it work on firefox. 但是我不能在Firefox上使用它。 i've read some comments about this editor and it states it may be due to the iframe. 我已经阅读了有关此编辑器的一些评论,并指出这可能是由于iframe所致。

here's my source if it will be helpful, text editor link 如果有用的话,这是我的资料来源, 文本编辑器链接

thank you in advance. 先感谢您。

<html>
    <head>
       <title>Rich Text Editor</title>
    </head>

    <script type="text/javascript">
    function def()
    {
        document.getElementById("textEditor").contentWindow.document.designMode="on";
        textEditor.document.open();
        textEditor.document.write('<head><style type="text/css">body{ font-family:arial; font-size:13px;}</style></head>');
        textEditor.document.close();
        document.getElementById("fonts").selectedIndex=0;
        document.getElementById("size").selectedIndex=1;
        document.getElementById("color").selectedIndex=0;
    }
    function fontEdit(x,y)
    {
        document.getElementById("textEditor").contentWindow.document.execCommand(x,"",y);
        textEditor.focus();
    }
    </script>

    <body onLoad="def()">
        <center>
            <div style="width:500px; text-align:left; margin-bottom:10px ">
                <input type="button" id="bold" style="height:21px; width:21px; font-weight:bold;" value="B" onClick="fontEdit('bold')" />
                <input type="button" id="italic" style="height:21px; width:21px; font-style:italic;" value="I" onClick="fontEdit('italic')" />
                <input type="button" id="underline" style="height:21px; width:21px; text-decoration:underline;" value="U" onClick="fontEdit('underline')" /> | 
                <input type="button" style="height:21px; width:21px;"value="L" onClick="fontEdit('justifyleft')" title="align left" />
                <input type="button" style="height:21px; width:21px;"value="C" onClick="fontEdit('justifycenter')" title="center" />
                <input type="button" style="height:21px; width:21px;"value="R" onClick="fontEdit('justifyright')" title="align right" /> | 
                <select id="fonts" onChange="fontEdit('fontname',this[this.selectedIndex].value)">
                    <option value="Arial">Arial</option>
                    <option value="Comic Sans MS">Comic Sans MS</option>
                    <option value="Courier New">Courier New</option>
                    <option value="Monotype Corsiva">Monotype</option>
                    <option value="Tahoma">Tahoma</option>
                    <option value="Times">Times</option>
                </select>
                <select id="size" onChange="fontEdit('fontsize',this[this.selectedIndex].value)">
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                    <option value="4">4</option>
                    <option value="5">5</option>
                </select>
                <select id="color" onChange="fontEdit('ForeColor',this[this.selectedIndex].value)">
                    <option value="black">-</option>
                    <option style="color:red;" value="red">-</option>
                    <option style="color:blue;" value="blue">-</option>
                    <option style="color:green;" value="green">-</option>
                    <option style="color:pink;" value="pink">-</option>
                </select> | 
                <input type="button" style="height:21px; width:21px;"value="1" onClick="fontEdit('insertorderedlist')" title="Numbered List" />
                <input type="button" style="height:21px; width:21px;"value="?" onClick="fontEdit('insertunorderedlist')" title="Bullets List" />
                <input type="button" style="height:21px; width:21px;"value="?" onClick="fontEdit('outdent')" title="Outdent" />
                <input type="button" style="height:21px; width:21px;"value="?" onClick="fontEdit('indent')" title="Indent" />
            </div>
            <iframe id="textEditor" style="width:500px; height:170px;">
            </iframe>
        </center>

    </body>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM