I’m trying to use jQuery to test for a css class applied to an anchor link inside a cross domain iFrame. This will then be used to trigger the visibility of some of the content on my site.
I’m very new to jQuery so what I’m trying is probably a hodge podge but, this is what I’ve got so far, hopefully it’ll better demonstrate what I’m trying to achieve.
$('#my_frame').load(function(){
var self = $(this);
if (self.contents().find('a.somelink').hasClass('someclass'))
{
alert('found it!');
}
});
I don’t want to change any of the iFrame content. I want the content of my site to change if there is an anchor link with a certain class attached to it inside the iFrame.
I have no control over the iFrame content.
Am I trying to achieve the impossible?
It is not possible to access the contents of a cross-domain child iframe. This is for security reasons. You cannot do it.