如何在不完全停用富文本编辑器的情况下隐藏 TinyMCE 工具栏 onBlur?
当用户单击另一个页面元素并离开文本区域(本质上是 onBlur)时,我试图隐藏 TinyMCE 工具栏。我找到了可以停用 onBlur 富文本编辑器功能的解决方案,但我只需要隐藏工具栏并保留富文本显示(而不是带有 html 标签的纯文本)。
任何建议将不胜感激...谢谢!
这就是我现在所拥有的:(它使用外部工具栏)
<html>
<head>
<!-- TinyMCE -->
<script type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "advanced",
plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
theme_advanced_buttons1 : "fontselect,fontsizeselect,|,bullist,numlist,|,outdent,indent,|,blockquote,image,code,|,fullscreen",
theme_advanced_buttons2 : "bold,italic,underline,strikethrough,sub,sup,hr,|,forecolor,backcolor,|,justifyleft,justifycenter,justifyright,justifyfull,|,link,unlink",
theme_advanced_buttons3 : "tablecontrols,|,charmap",
theme_advanced_toolbar_location : "external",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true
});
</script>
</head>
<body>
<form method="post" action="somepage">
<br />
<br />
<br />
<br />
<br />
<textarea name="content1" id="content1" style="width: 500px;">
This is some sample <b><u>content</u></b>.
</textarea>
<br />
<br />
<a href="javascript: void(0);" onclick="tinyMCE.getInstanceById('content1').toolbarElement.style.display = 'none'">Hide Toolbar</a>
</form>
</body>
</html>
I am attempting to hide the TinyMCE Toolbar when a user clicks on another page element and leaves the text area (so essentially onBlur). I have found solutions that will Deactivate the Rich Text Editor functionality onBlur, but I need to only hide the toolbar and leave the Rich Text display (rather than plain text with html tags).
Any suggestions would be greatly appreciated...thanks!
This is what I have now: (it uses the external toolbar)
<html>
<head>
<!-- TinyMCE -->
<script type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "advanced",
plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
theme_advanced_buttons1 : "fontselect,fontsizeselect,|,bullist,numlist,|,outdent,indent,|,blockquote,image,code,|,fullscreen",
theme_advanced_buttons2 : "bold,italic,underline,strikethrough,sub,sup,hr,|,forecolor,backcolor,|,justifyleft,justifycenter,justifyright,justifyfull,|,link,unlink",
theme_advanced_buttons3 : "tablecontrols,|,charmap",
theme_advanced_toolbar_location : "external",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true
});
</script>
</head>
<body>
<form method="post" action="somepage">
<br />
<br />
<br />
<br />
<br />
<textarea name="content1" id="content1" style="width: 500px;">
This is some sample <b><u>content</u></b>.
</textarea>
<br />
<br />
<a href="javascript: void(0);" onclick="tinyMCE.getInstanceById('content1').toolbarElement.style.display = 'none'">Hide Toolbar</a>
</form>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下代码在焦点处弹出工具栏,并在用户单击编辑器外部的某个位置时将其隐藏。此解决方案已针对 Safari 和 Firefox 进行了测试,但也应该适用于 Internet Explorer。
我的bindEvent函数如下:
希望这对您(或某人)有帮助。
The following code pops up the toolbar at focus and hides it when the user clicks somewhere outside the editor. This solution was tested for Safari and Firefox, but should also work for Internet Explorer.
My bindEvent function is as follows:
Hope this helps you (or someone).
这应该可以完成工作
或者,您可以使用带有以下课程的中途停留(div)
This should do the job
Alternatively, You could use a layover (a div) with the following class