Scenario:
'Parent Page' contains two iframes, 'activity_overview' and 'upload_avatar'. 'Activity_Overview' contains a page on the same domain. 'Upload_avatar' also contatins a page on the same domain, which contains a form. When the form (which submits a new avatar img) in 'upload_avatar' is submitted, it automatically opens a new page in the 'activity_overview' window which contains the uploaded image.
What I would like to do, is get the img src from this image and pass that to a couple of divs in my parent page, so that those images refresh along with (or shortly after) the reload of the 'activity_overview' iframe.
I've tried a number of things including passing the src as a variable, from php to js, setInterval to keep checking if the img var is defined yet..etc. The following code is what seems simplest and ideal to me, but the page reload in the iframe is not detected.
$(document).ready(function(){
function avatarUpdate(){
$('#avatar-crop-submit').click(function () {
$('#avatar-upload-form').submit(function() {
$('#avatar-upload-form').attr('target','activity_overview');
window.parent.$("#overview-list, #overview").addClass('active');
window.parent.$("#edit-list, #edit").removeClass('active');
window.parent.$('#upload_avatar').attr('src', 'www.example.com/form/');
$('#activity_overview').on('load', function(){
var avatar_src = $('#temp_header_avatar img').attr('src');
window.parent.$('#header_avatar').html('<img src="' + avatar_src + '" class="avatar user-1-avatar avatar-150 photo" width="150" height="150" alt="Profile Photo">').hide().fadeIn(1000);
window.parent.$('#nav_avatar').html('<img src="' + avatar_src + '" class="avatar img-circle user-1-avatar avatar-60 photo" width="60" height="60" alt="Profile Photo">').hide().fadeIn(1000);
});
});
});
}
avatarUpdate();
});
I thought this question may have some relevance, but I am not sure how to implement the solution.