2

I want to close the child tab and refresh the parent tab scenario.

script

function closeRefresh(){      
        window.opener.location.href="/{!$CurrentPage.parameters.id}";
        window.top.close();
       }

This script is working fine in Chrome but it is not working in IE .In IE the child tab itself refreshing and loading the parent page in the child tab.

2

2 Answers 2

1

For IE window.opener will not work you have to use window.showModalDialog. You can pass parameters from parent to child as well as child to parent. window.showModalDialog return a value to parent based upon that you can refresh the parent. window.showModalDialog will work for IE and FF you have to handle in JavaScript accordingly. Here is a parent child example.

parent.html

<html>
<body>
<script language="JavaScript">
function openWindow() {
   var myArguments = new Object();
   myArguments.bgcolor = document.all.myColor.value;
   var dialogResults = window.showModalDialog("child.html", myArguments, '');
   if ( (dialogResults != undefined) && (dialogResults != '') && (dialogResults != false) ){
      alert(dialogResults);
      window.location=window.location;
   }
} 
</script>
<select id="myColor">
    <option value="red">Red</option>
    <option value="green">Green</option>
    <option value="blue">Blue</option>
    <option value="yellow">Yellow</option>
</select>
<button onclick="openWindow();">Open window</button>
</body>
</html>

child.html

<html>
<head>
  <script>
    var oMyObject = window.dialogArguments;
    var bgColor = oMyObject.bgcolor;    
    function closeWindow() {
        alert(bgColor);
        window.returnValue = 'Refresh';
        window.close();
    }
  </script>
</head>

<body>
    <a href="#" onClick="closeWindow();">Click here to close the window</a>
</body>

</html>
0

Sounds like you are using the console? If that's the case then you will need to look at the Console Integration Toolkit.

Here's a link to the example from Salesforce https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_sample_vf.htm

Make sure you pay particular attention to their best practices: https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_best_practices.htm

If you aren't using Console then try this: https://salesforce.stackexchange.com/a/46195/11369 .

1
  • Iam not using console ...
    – srini
    Commented Sep 25, 2015 at 19:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .