susanahernandezd
7/1/2013 - 7:55 AM

Know parent URL of iframe

Know parent URL of iframe

$(document).live('click', '#cupon_danet3D', function(event){
    var re = /(.*)danet(.*)/g,
        //url = document.referrer,
        url = document.location.ancestorOrigins[0],
        matched = url.match(re);

    if(matched){
        event.preventDefault();
        var urlCupon = $('#cupon_danet3D').attr('href'),
            paramDanet = '?utm_source=Danetiframe&utm_medium=Banner_Cupon&utm_campaign=Imprime_Cupon_Productos';
            window.open(urlCupon+paramDanet);
    }
    //console.log('HEI: '+matched);
});