I want to access element and its events and properties from child document which is in <iframe>
and that <iframe>
added into the page.
I have a survey and that I'm including into the page using <iframe>
. I want to trigger events from the survey to so when I'm comes on survey page the Lead Facebook pixel code fires and when survey completed the CompleteRegistration Facebook pixel code fires. So I'm trying to access some actions/events from <iframe>
to fires FB pixel code.
Both documents are on the same server, but it's not working.
I've tried this:
$(document).ready(function() {
$('#assessment').load(function(){
var iframe = $('#assessment').contents();
iframe.find("h1 .state__title").click(function() {
alert("test");
});
});
});
Also this:
var a = window.frames['assessment'].contentDocument.getElementsByClassName('h1').innerHTML;
alert(a);
Any help is welcome. Thanks in Advance.