javascript 如何禁用 TinyMCE 确认对话框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5705671/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to disable TinyMCE confirm dialog
提问by locrizak
Does anyone know how to disable TinyMCE alerts, and confirms. The confirm in talking about says:
有谁知道如何禁用 TinyMCE 警报并确认。谈论中的确认说:
This page is asking you to confirm that you want to leave - data you have entered may not be saved Leave Page - Stay on Page
此页面要求您确认是否要离开 - 您输入的数据可能不会被保存 离开页面 - 留在页面
I've written my own stuff that detects if the page data has been change so I don;t want TinyMCE to worry. I found the function in the TinyMCE source so I'm about to overwrite it but I want to know if anyone knows a better way to accomplish this. Thanks.
我已经编写了自己的东西来检测页面数据是否已更改,所以我不想让 TinyMCE 担心。我在 TinyMCE 源代码中找到了该函数,因此我将覆盖它,但我想知道是否有人知道实现此目的的更好方法。谢谢。
回答by Wesley Murch
To remove the message, just disable the autosave
plugin, that's what adds the onunload
prompt.
要删除消息,只需禁用autosave
插件,这就是添加onunload
提示的内容。
Simply don't load the plugin in your TinyMCE initialization script.
只需不要在您的 TinyMCE 初始化脚本中加载插件。
回答by locrizak
As per a request I'm adding this here to show my solution which has worked great:
根据要求,我在此处添加此内容以展示我的解决方案,该解决方案非常有效:
My soultion thanks to a link provided by Madmartigan, on the TinyMCE forum. Getting rid of the autosave plugin did not work, I ended up writeing this:
感谢Madmartigan在TinyMCE 论坛上提供的链接。摆脱自动保存插件不起作用,我最终写了这个:
window.onbeforeunload = function() {};
And it got rid of the popup. Looks like it could be a bug with TinyMCE, since the init code I have I copied off their demo.
它摆脱了弹出窗口。看起来这可能是 TinyMCE 的一个错误,因为我从他们的演示中复制了初始化代码。
回答by Jojje
I set it as a param when initializing (autosave_ask_before_unload):
我在初始化时将它设置为参数(autosave_ask_before_unload):
tinymce.init({
mode: 'textareas',
menubar: false,
statusbar: false,
language: 'sv_SE',
autosave_ask_before_unload: false,
...
回答by Bobby Etheredge
Neither of the above answers worked for me with Joomla 3.3.2 and JCE 2.5.11. Although this did work: Inside the file -
上述答案都不适用于 Joomla 3.3.2 和 JCE 2.5.11。虽然这确实有效:在文件内 -
components/com_jce/editor/tiny_mce/plugins/autosave/editor_plugin.js,
组件/com_jce/editor/tiny_mce/plugins/autosave/editor_plugin.js,
I changed
我变了
editor.getParam("autosave_ask_before_unload",TRUE)
editor.getParam("autosave_ask_before_unload",TRUE)
to
到
editor.getParam("autosave_ask_before_unload",FALSE)
editor.getParam("autosave_ask_before_unload",FALSE)
Apparently on autosave unload, it prompts the confirm box. This disables the unload confirm completely. From what I tested, it worked in IE, Chrome, and FF.
显然在自动保存卸载时,它会提示确认框。这将完全禁用卸载确认。根据我的测试,它可以在 IE、Chrome 和 FF 中运行。
回答by stephen.hanson
If the problem you're having is just that the content isn't actually dirty, maybe because you replaced it programmatically, you can explicitly mark the editor as not dirty like this:
如果您遇到的问题只是内容实际上并不脏,也许是因为您以编程方式替换了它,您可以像这样明确地将编辑器标记为不脏:
tinyMCE.activeEditor.isNotDirty = true