Javascript jquery iframe事件与mozilla一起使用?
我使用html5所见即所得编辑器。编辑器以友好方式加载iframe,我想在此编辑器上监视Javascript jquery iframe事件与mozilla一起使用?,javascript,jquery,wysihtml5,Javascript,Jquery,Wysihtml5,我使用html5所见即所得编辑器。编辑器以友好方式加载iframe,我想在此编辑器上监视keydown事件 加载的iframe如下所示: <iframe class="wysihtml5-sandbox" security="restricted" allowtransparency="true"> <html> <head><meta charset="UTF-8"></head> <body marginwidth=
keydown
事件
加载的iframe如下所示:
<iframe class="wysihtml5-sandbox" security="restricted" allowtransparency="true">
<html>
<head><meta charset="UTF-8"></head>
<body marginwidth="0" marginheight="0" id="descriptionkb" contenteditable="true"
class="form- control editor wysihtml5-editor" spellcheck="true"
style="color: rgb(85, 85, 85); cursor: auto; font-family: Arial, Helvetica, sans-serif;
font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal;
line-height: 20px; letter-spacing: normal; text-align: start; text-decoration: none;
text-indent: 0px; text-rendering: auto; word-break: normal; word-wrap: break-word;
word-spacing: 0px; background-color: rgb(255, 255, 255);">
<span id="_wysihtml5-undo" class="_wysihtml5-temp"></span>
</body>
</html>
</iframe>
这对chrome和IE非常有效,但对mozilla不起作用。我尝试过不同的方式来访问这个活动,但没有一种在mozilla中起作用。我错在哪里?引用
在注册之前,请确保所见即所得HTML iframe已完全加载
类似这样的事件,否则结果可能因浏览器而异。单程
为了确保iframe完全加载,需要定义如下函数
上面的代码作为编辑器“load”函数的回调
哦,我完全忘记了加载,因为它在其他浏览器上运行时没有加载。。。加载后,它与mozilla一起工作。这是我第一次喜欢IE。
$('iframe.wysihtml5-sandbox').contents().on('keydown', '#descriptionkb', function(e){
// execute code on keydown event
});