2
我將TinyMCE在我的ASP.NET MVC4 web應用程序插件光標位置。我也使用SignalR來建立服務器和客戶端之間的開放連接。我想要做的是一個類似於Google Docs的實時編輯器。問題與在Firefox
直到現在我設法找到一種方式,在一個瀏覽器的編輯器編寫,並把它顯示在另一個瀏覽器另一個打開的文檔。我之前遇到了遊標位置問題,因爲當我在tinyMCE中使用setContent()方法時,遊標被放在前面,因此輸出反轉。
這是解決了這兩個語句:
ed.selection.select(ed.getBody(), true);
ed.selection.collapse(false);
但是現在我的問題是,Chrome瀏覽器的輸出是因爲我想爲它是即用光標在後面寫但是當我從Firefox瀏覽器寫入,空格按鈕被忽略,當我按下空格時,光標會回退。
有什麼特別的原因爲什麼會這樣?另外,連接速度似乎有問題,即當我輸入最新的內容(1或2個字母)時沒有提交。
這是所有的代碼,我有一個關於這個問題:
@{
ViewBag.Title = "- Editor";
ViewBag.ContentStyle = "/Content/CSS/editor.css";
}
<script src="/Scripts/jquery-1.6.4.min.js" ></script>
<script src="/Scripts/jquery.signalR-1.0.0.js"></script>
<script src="/signalr/hubs"></script>
<script type="text/javascript" src="~/Content/tinyMCE/tiny_mce.js" ></script>
<script type="text/javascript" src="~/Scripts/EditorHandler.js"></script>
<script type="text/javascript">
$(function() {
tinyMCE.init({
mode: "textareas",
theme: "advanced",
plugins: "emotions,spellchecker,advhr,insertdatetime,preview",
// Theme options - button# indicated the row# only
theme_advanced_buttons1: "newdocument,|,bold,italic,underline,|,justifyleft,justifycenter,justifyright,fontselect,fontsizeselect,formatselect",
theme_advanced_buttons2: "cut,copy,paste,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,|,code,preview,|,forecolor,backcolor",
theme_advanced_buttons3: "insertdate,inserttime,|,spellchecker,advhr,,removeformat,|,sub,sup,|,charmap,emotions",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_statusbar_location: "bottom",
theme_advanced_resizing: false,
setup: function (ed) {
ed.onKeyUp.add(function (ed, e) {
var chat = $.connection.editorHub;
chat.client.broadcastMessage = function (message) {
tinyMCE.activeEditor.setContent(message);
ed.selection.select(ed.getBody(), true);
ed.selection.collapse(false);
tinyMCE.activeEditor.focus();
};
$.connection.hub.start().done(function() {
var text = tinyMCE.activeEditor.getContent();
chat.server.send(text);
});
});
}
});
});
</script>
<form method="post" action="somepage">
<textarea id="editor" name="content" cols="100" rows="30"></textarea>
</form>
試圖使用這個剛纔..仍與firefox中的間隔相同的問題!感謝您的回答 :) – Bernice 2013-02-28 13:09:58