我一直在使用Aloha Editor创建example of a simple editor,但是我没有成功使其在Opera中工作。菜单不出现,并且文本区域不可编辑。
在所有其他浏览器中似乎都可以正常工作,但是Chrome有时需要刷新页面才能正常工作。
这是相关的HTML代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="//cdn.aloha-editor.org/latest/css/aloha.css" rel="stylesheet" media="screen" />
</head>
<body>
<textarea id="content"></textarea>
<script src="//cdn.aloha-editor.org/latest/lib/require.js"></script>
<script src="//cdn.aloha-editor.org/latest/lib/aloha.js" data-aloha-plugins="common/ui,common/format,common/table,common/list,common/link,common/block,common/undo,common/contenthandler,common/paste"></script>
<script src="notes.js"></script>
</body>
</html>
这是javascript代码(在notes.js内部):
var Aloha = window.Aloha || ( window.Aloha = {} );
Aloha.settings = { sidebar: { disabled: true } };
Aloha.ready(function () {
Aloha.jQuery('#content').aloha();
});
预先感谢您的想法!
最佳答案
阅读Inshallah的评论后,我正在回答自己的问题。
问题在于,应在包含Aloha之前设置javascript变量Aloha和Aloha.settings。
HTML代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="//cdn.aloha-editor.org/latest/css/aloha.css" rel="stylesheet" media="screen" />
</head>
<body>
<textarea id="content"></textarea>
<script src="//cdn.aloha-editor.org/latest/lib/require.js"></script>
<script>
var Aloha = window.Aloha || ( window.Aloha = {} );
Aloha.settings = { sidebar: { disabled: true } };
</script>
<script src="//cdn.aloha-editor.org/latest/lib/aloha.js" data-aloha-plugins="common/ui,common/format,common/table,common/list,common/link,common/block,common/undo,common/contenthandler,common/paste"></script>
<script src="notes.js"></script>
</body>
</html>
Javascript代码(在notes.js内部)
Aloha.ready(function () {
Aloha.jQuery('#content').aloha();
});
关于javascript - Aloha编辑器在Opera上不起作用,有时在Chrome上不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12222475/