views:

67

answers:

1

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?

A: 

I don't know the background behind this but it looks like IE won't window.open into an existing window - maybe for security purposes, I don't know.

You could try replacing newwin by something random (different) every time, which will open a new window every time you call showImageBrowser().

Pekka
Will try but that doesnt make sense because the window does get closed in `selectFile()` it's just when its re-opened :-S
fire
@fire ah, I misread that part. That is indeed strange.
Pekka