function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Coco_SdyneyCoco_Sdyney 

Javascript refresh parent window from child not working in IE and Chrome

Hi,

 

I am made a button on contact page to open a VF page in new window, and wish to refresh the contact page when I click Submit in the VF page.

 

My VF page contains iframe, so I write javascript as below 

 

function refreshparent()

{

top.window.opener.location.href= '/' + id;

}

 

on button:

<apex:commandButton action="{!Submit}" value="Submit" onComplete="refreshparent('{!Contact.Id}')"/> 

 

This works find in Firefox, but not working in IE neither Google Chrome, any one has ideas to help me?

 

Thank you very much!!!

bob_buzzardbob_buzzard

The way I access the parent page for a popup is:

 

      var winMain=window.opener;
      if (null==winMain)
      {
         winMain=window.parent.opener;
      }
      // do what I need to do with winmain

This works for me across firefox, ie and chrome, though I'm hitting a javascript function embedded in a parent visualforce page rather than trying to change the location of the page.

Coco_SdyneyCoco_Sdyney

Thanks Bob, I tried this piece of code but unfortunatly it not works for me, none of IE , Firefox or Chrome.  :(

bob_buzzardbob_buzzard

Have you checked for javascript errors?  It might be that the browser is blocking the attempt as a cross site scripting attack.