Reputation: 2307
How do i call a JQuery plugin function from within an iframe?
(function($){
$.fn.jqueryEx = function() {
function CallThisFunctionFromIframe(){
}
}
})(jQuery);
The iframe is on the same domain as parent document.
Upvotes: 3
Views: 892
Reputation: 2307
(function($){
$.fn.jqueryEx = function() {
$.fn.jqueryEx .CallThisFunctionFromIframe= function() {
alert('hello');
}
}
})(jQuery);
Call this from within the iframe
$(document).ready(function() {
window.parent.$.fn.jqueryEx.CallThisFunctionFromIframe();
});
Upvotes: 2
Reputation: 7243
I can suggest you this approach. Just wrap the logic you want to call into the function.
<script type="text/javascript">
//<![CDATA[
function CalledFromChild() {
// Stuff triggered from child
alert("What ever");
}
//]]>
</script>
and in the iframe you can do so.
<script type="text/javascript">
//<![CDATA[
window.parent.CalledFromChild();
//]]>
</script>
Upvotes: 0