user655334
user655334

Reputation: 1015

jQuery handle mouse events inside IFRAME

I am using Iframe for displaying book content (epub format).

I able to changing the book background color and book font-size.

But i am not able to call the event handlers inside IFRAME using jquery.

my javascript code is in the following way :

$('#bookcontentHeight').contents().find('body').bind("mouseup", function(e) {       
            alert('inside');
            e.preventDefault();         
            $("#custom-menu").css({ top: e.pageY + "px", left: e.pageX + "px" }).show(100);
        });

Upvotes: 0

Views: 1025

Answers (1)

502_Geek
502_Geek

Reputation: 2126

Hope can work from these two option.

var iframe = $("#bookcontentHeight");
$(".body",iframe.get(0).contentDocument).mouseup(function(){alert('Hello')});

or

$("#bookcontentHeight").contents().find(".body").bind("mouseup", function() { alert("Hello"); });

Upvotes: 2

Related Questions