我在iframe格式中使用nicEdit。每次用户在编辑器中写入任何内容(keyup事件)时,我都需要运行另一个js / jquery函数。如何将此自定义键盘操作添加到所需的iframe?
答案 0 :(得分:1)
答案实际上在于js代码。在nicEdit.js中搜索:
var nicEditorIFrameInstance = nicEditorInstance.extend({
在其中,在initFrame
函数中,
寻找this.frameDoc.addEvent
。
这是添加事件的地方(通过addEvent)。其中包括您的密钥语句:
addEvent('keyup',this.YOURFUNCTIONAME.closureListener(this))
您需要添加closureListener(this)
才能使其正常工作。然后在initFrame函数之后创建YOURFUNCTION:
YOURFUNCTIONAME: function() {
//Do what you like. Probably call any JS function that lies in the file where
//you have included the nicEdit.js
},
这种方法对我有用。希望它也适合你。 nicEdit是迄今为止我遇到的最糟糕的第三方记录。