Javascript Ckeditor获取鼠标点击位置 [英] Javascript Ckeditor Get Mouse click position
本文介绍了Javascript Ckeditor获取鼠标点击位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Ckeditor
I am using Ckeditor
查看:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="~/Content/ckeditor/ckeditor.js"></script>
<input id="insertPattern" type="button" value="insert pattern" />
@Html.TextArea("editor", new { @class = "ckeditor", id = "aboutme" })
Javascript:
$(function () {
$('input#insertPattern').click(function () {
var txtarea = document.getElementById("aboutme");
var selection = txtarea.getSelection().getStartElement().getOuterHtml();
alert(selection);
}});
如果我点击buton,我不能提醒选择数量的鼠标点击Html.TextArea在Ckeditor。
If i click to buton , i can not alert selection number of mouse click in Html.TextArea in Ckeditor.
错误:
在此JavaScript代码部分
In this part of javascript code
var selection = txtarea.getSelection().getStartElement().getOuterHtml();
我得到以下错误:
未捕获的类型错误未定义不是函数
uncaught typeerror undefined is not a function
推荐答案
最终你想要插入文本,点对。这段代码做到了。
Ultimately you want to insert text where exactly the mouse points right. This piece of code do that.
CKEDITOR.instances['aboutme'].insertText("insert some text into this string");
这篇关于Javascript Ckeditor获取鼠标点击位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文