I am trying to find a focused element in an iframe but it fails!
Whenever I insert in an iframe, the element seems focused, for example, if I insert a table, then the cursor is always in the last cell.
As test I, I try to change the background color of the cell to see if it works, but this always changes the body of the iframe, not the inserted element
var d1 = $.Deferred(); $.when(d1).then(function () { var $iframe = $("#ifr").contents(); var focused = $iframe.find(':focus'); focused.css("background", "red"); console.log(focused); }) d1.resolve(insertTable(html));
d1 is just a function call that uses execCommand () to insert into an iframe.
Is it possible to find a focused element and save it in this method?
source share