IE8 window.opener problems

Posted by fire on Stack Overflow See other posts from Stack Overflow or by fire
Published on 2010-05-17T16:17:37Z Indexed on 2010/05/17 16:20 UTC
Read the original article Hit count: 471

Filed under:
|

Having problems with IE8...

I have a button that onclick fires the showImageBrowser() function.

function showImageBrowser(params) {
var open = window.open('http://localhost/admin/browse?'+params,'newwin','toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=950,height=500');
    if (!open) {
        alert('Could not open the image browser, please disable your popup blocker.');
    }
}

Now in the image browser when you click on an image it calls this function:

function selectFile(url, el) {
    window.opener.replaceImage('Test_Image', url);
    window.close();
}

Which is calling the replaceImage() function in the parent window, as expeted.

This is the code:

function replaceImage(el, url) {
  $('#'+el).html('<a href="'+url+'" target="_blank" class="image">'+basename(url)+'</a>');
  $("input[name='"+el+"']").val(url);
}

Now if you click on the original showImageBrowser() button for the second time, IE will bring up the window but this time it freezes for a few seconds and then you get the alert "Could not open the image browser, please disable your popup blocker."

This works fine in Firefox (obviously) but not in IE. I haven't even tried it in IE7/6 because if it doesn't work in 8 then I know I'm going to have problems.

Any advice?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery