Joax23
Joax23

Reputation: 25

Lightbox iFrame problem

I have an iFrame that is loaded with a lightbox. The problem I am having is this. I want the parent page to redirect to a different page after a link in the lightbox pop up is clicked. Does this make sense? Please help. Thank you in advance.

I received this answer yesterday from yokoloko (thank you very much) But I am not sure which parts of the code I have to fill in with my information. Can somebody please help? Thanks.

From Yokoloko:

The only way is to define a javascript function in your parent frame to be called in your child frame.

eg in your parent frame if your using jQuery :

function redirectFromFrame(link){
    window.location.href = link;
}

and in your lighbox frame you should have something like this.

$(function() {
    $('a').click(parent.redirectFromFrame($(this).attr('href')));
});

Upvotes: 0

Views: 1745

Answers (1)

LeeR
LeeR

Reputation: 1636

I would just use something like this (and this code goes within your iframe)

$(function() {
    $('a').click(function() {
        window.parent.location.href=$(this).attr('href');
    });
});

the $('a') refers to the a tag within your iframe that you want the redirection to take place on

Upvotes: 1

Related Questions