I'm trying to write my own WYSIWYG Editor with jQuery!
I need to catch events which fired on the editor's frame. The "click"
event is working fine and has the right current element, but "keyup"
returns only <body>
as current tag in any place! What did I do wrong?
<iframe id="editor"></iframe>
<script>
// Define editor
var editor = $('#editor').contents().find('body');
// Switch to design mode
$('#editor').contents().prop('designMode', 'on');
editor.on("click", function(event) {
console.log("clicked:" + event.target.nodeName + $(this).prop("tagName") + $(event.target).prop("tagName"));
});
editor.on("keyup", function(event) {
console.log("key:" + event.target.nodeName + $(this).prop("tagName") + $(event.target).prop("tagName"));
});
</script>
There is example: jsfiddle.net/p38L10zp/1