当我使用tinyMCE.execCommand添加一些文本时,它会显示几秒钟然后自动撤消。
尝试了解撤消级别的工作原理。 如何添加撤消/管理级别?
使用的代码的缩减版本:
<html>
<head>
<title>TinyMCE editor</title>
<script type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="jquery/jquery-1.10.2.js"></script>
<script type="text/javascript" src="jquery/jquery-ui.js"></script>
<script type="text/javascript">
var toolbar =
"fontselect,fontsizeselect, formatselect, bold,italic,underline,|," +
"forecolor,backcolor,|,removeformat,cleanup,|,codemirror2,charmap,|,fullscreen";
var toolbar2 =
"undo,redo,|,pastetext,pasteword,|,bullist,numlist,|,outdent,indent,|," +
"justifyleft,justifycenter,justifyright,justifyfull,|,link,unlink,anchor,image";
var initHtmlMode = {
mode: "textareas",
theme: "advanced",
theme_advanced_buttons1: toolbar,
theme_advanced_buttons2: toolbar2,
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_statusbar_location: "bottom",
theme_advanced_resizing: true
};
tinyMCE.init(initHtmlMode);
function showList() {
tinyMCE.execCommand('mceInsertContent', false, 'some text');
}
</script>
</head>
<body>
<form>
<textarea id="content" rows="15" style="width: 80%"></textarea>
<br/>
<button onclick="showList()">Insert</button>
</form>
</body>
</html>
答案 0 :(得分:0)
onclick()正在刷新页面
<form onsubmit="return false">
修正了它。