0

I would like to run the script in parent when .gridlove-sidebar-action is in iframe. Iframe is NOT in the same domain, but AccessControlAllowOrigin is "activated" in htaccess, css and script is working except this. The script is working if iframe is in same domain. I own the two domains.

Iframe :

<iframe id="followblog" src="http://example.com/iframe.html"></iframe>

In the Iframe :

<span class="gridlove-sidebar-action">
    <a class="#" href="#">
    My button
    </a>        
</span>

Script to run in parent :

$('#followblog').load(function(){

    var iframe = $('#followblog').contents();

    iframe.find(".gridlove-sidebar-action").click(function(){
        $('body').addClass('gridlove-sidebar-action-open gridlove-lock');
        $('.gridlove-sidebar-action-wrapper').css('top', gridlove_admin_top_bar_height);
    });
});

htaccess :

SetEnvIf Origin "http(s)?://(www\.)?(example.com)$" AccessControlAllowOrigin=$0$1
Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
Header set Access-Control-Allow-Credentials true
Mathieu
  • 797
  • 2
  • 6
  • 24

1 Answers1

0
// Defined in Parent window 
function defInParent(code){

}

// Call from Child iFrame 
window.opener.authSuccessWithCode(code);
MyTwoCents
  • 7,284
  • 3
  • 24
  • 52