Jquery and binding an event to an iframe
- by dbr
**I'm currently using a jquery textselect plugin to fire alerts based on the selection text anywhere on the page
and it works just fine doing something like:
$(document).ready(function() {
$(document).bind('textselect', function(e) {
alert(e.text);
});
});
I've since had to add an iframe to the page and I need the text selection to work on text within the
iframe as well. I'm trying to do something like this but it's not working:
$(document).ready(function() {
$('#iframeId').load(function() {
$(document.getElementById("iframeId").contentWindow).bind('textselect',function(e) {
alert(e.text);
});
});
At this point I've tried a whole mess of ways to reference the iframe document without any success. Any ideas?**