Forum Moderators: open

Message Too Old, No Replies

window.opener not working on IE

window.opener,not working,IE7,IE8

         

ALKateb

2:43 pm on Oct 19, 2009 (gmt 0)

10+ Year Member



Hello!
i have a page that opens a popup and i want this new popup to call a function on the original page or at least to change its location ... i tried to use window.opener and it worked fine in fire fox but not on IE!
here is the code i used

<script language="javascript" type="application/javascript">
window.opener.location.reload(true);
window.close();
</script>

this is working fine on fire fox but not on IE! any ideas?

Fotiman

4:26 pm on Oct 19, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I haven't tried it yet, but I notice a couple of things.
1. Your type value is not correct. Use type="text/javascript" instead.
2. The language attribute is invalid and pointless. Don't use it.

If I was to venture a guess, I would guess that IE doesn't like the "application/javascript" type. But I haven't been able to test this theory.

rocknbil

4:30 pm on Oct 19, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



First,

<script type="text/javascript">

not

<script language="javascript" type="application/javascript">

Language attribute is deprecated and not needed.

Second, try

window.opener.document.location.reload()

However, if the page loaded in window.opener is a result from a submitted form it will give you "data needs to be resubmitted" warning. It may be better to pass variables to your function and build a query string, like


// Be sure to use the logical "or" pipe character, not ¦¦
function reloadParent(pid,state,func) {
if ((! pid) ¦¦ (! state)) {
alert('Record ID and display required to close and refresh.');
return;
}
if (window.opener && !window.opener.closed) {
//window.opener.document.location.reload()
window.opener.document.location='yourscript?'+func+'='+state+'&id='+pid;
window.close();
}
}

ALKateb

10:40 am on Oct 21, 2009 (gmt 0)

10+ Year Member



thanks a lot guys for your help it's working now and it all was cos of this stupid "application/javascript" attribute
when i changed it to text/javascript it worked fine
rocknbil
thanks for the example and ure right it's better than to reload the page but i dont have to worry about this cos once any user logged in they will be redirected and there will be no submitted form anymore so i dont have to worry about this
and actually now i'm redirecting the page instead of reloading it anyway redirecting it to the product page in case the user sailed away from the original page during working on the popup page
thanks again for ur help