jHtmlArea 按键事件处理
我目前正在开发一个文本到符号的转换工具(非盈利),我遇到了这个问题:
对于文本的所见即所得编辑,我想使用一个漂亮的小型所见即所得编辑器(例如 jHtmlArea )。这个编辑器将显示浮动的div,所以我必须拦截很多按键(空格/箭头/等)
目前,我的html区域是这样加载的:
<script type="text/javascript">
$(function() {
$("#txtCustomHtmlArea").htmlarea({
loaded: function() {
$(this.editor).keydown(function(event) {
if(event.keyCode == 32) {
this.pasteHTML('<b>test</b>');
return false;
}
return true;
});
}
这段代码的问题是 this.editor 没有方法pasteHTML。如何使用 this(=htmlarea).event 中的此方法?
这很可能是一个相当初学者的问题,但我真的不知道该去哪里寻找。
谢谢
I'm currently developping a text-to-symbol conversion tool (non-profit), and I'm having this problem:
For the WYSIWYG-editting of the text, I'd like to use a nice small wysiwyg editor (like jHtmlArea). This editor will show floating divs, so I'll have to intercept a lot of keypresses (spaces/arrows/etc)
Currently, my html area is loaded like this:
<script type="text/javascript">
$(function() {
$("#txtCustomHtmlArea").htmlarea({
loaded: function() {
$(this.editor).keydown(function(event) {
if(event.keyCode == 32) {
this.pasteHTML('<b>test</b>');
return false;
}
return true;
});
}
The problem with this code is that this.editor doesn't have the method pasteHTML. How can I use this method from this(=htmlarea).event?
This is most probably a fairly beginner question, but I'm really clueless towards where to look.
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我是这样做的:
然后我可以参考:
这也为我提供了从 iFrame 外部访问 html 区域对象的句柄。
Here's how I do it:
Then I can reference:
This also gives me a handle to my the html area object from outside of the iFrame.
我认为您可能对“this”的使用感到困惑(我确实在努力跟踪它所指的内容!)。
作为测试,您可以将 替换
为
或 Maybe
,看看是否有帮助?
I think you're maybe getting yourself confused with the use of 'this' (I am definitely struggling to keep track of what it refers to!).
As a test, can you replace the
with
or maybe
and see if that helps?