Question

I have a popup window that I need to access click, change or any other event as well as elements values for input and move them to parent window element

example popup window html:

<a href="#" class="button">Add image</a>

<input type="text" id="imagelink" value="link_to_image" />

parent window html:

<img id="logo_image" src="default_image_link" />

start js:

window.addEvent('domready', function(){ 


   $$('.button').addEvent('click', function(){
   var img_src =  $('imagelink').get('value');
    $('logo_image').set('src',img_src);

   });

});

when user clicks on a.button in child window , I need to replace src property of parent window #logo_image with value from input #imagelink

Was it helpful?

Solution

You can do it by accessing window.opener property of popup window which points to parent window:

window.opener.document.getElementById('logo_image').setAttribute('src', img_src);

Or if you also have MooTools in parent window:

window.opener.$('logo_image').set('src',img_src);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top