calling a function from child window using window.opener works in IE but not in Firefox

1.4k views Asked by At

I'm working on a site that has three frames. A top frame, main frame and a bottom frame named topFrame, mainFrame, bottomFrame in the frameset. Nothing unusual.

Working in the mainFrame, I have a page called view.html that contains a function called refresh_status().

It looks like this:

function refresh_status() {
   alert ("inside of refresh status function");
   // do stuff  
}

Also, from this page (view.html), I simply pop open (from a link) a new child window like this:

Link looks like this....

<a href="javascript:popUpstatus('status.html')">Update</a>

Function that pops open new window....

function popUpstatus(URL) {
status = window.open(URL,     'status','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=670,height=600');
}

The status.html file pops open normally in a new child window. In the child window, I have a link from which I'm trying to fire the refresh_status() function in the parent window (view.html).

In the child pop up (status.html), this is the link....

<a name="select_anchor" href="#">Refresh</a>

The javascript in status.html looks like this....

<script type="text/javascript">
    function new_status() {
    window.opener.refresh_status();
}

$(document).ready(function() {
    $("a[name='select_anchor']").click(new_status());

});
</script>

IE8 will fire the refresh_status() function in the parent window and triggers the alert as expected, however Firefox complains and says that window.opener.refresh_status() is not a function. Any ideas?

1

There are 1 answers

0
krasu On

If you want call new_status at click on link event you just need to remove braces

 $("a[name='select_anchor']").click(new_status);

because when you are write this

 $("a[name='select_anchor']").click(new_status());

you are set result of function as event handler