1
<apex:commandButton value="Search Again" onclick="return window.open('/apex/customreport');window.top.close();" />

it is opening one new window and the old window is also there .

when the button is clicked it has to close the current window and open the new window which i wrote above .answer would be great helpful

  • why would you want it? why not just update the current window link/URL? Can you detail more on the reason/logic that this is needed in such a way? – Saariko Feb 11 '14 at 14:22
1

You can replace "window.top.close()" with just "window.close()". It should work with IE & Chrome.

window.close() - is JavaScript function to close current window. But it's implementation is browser specific. It may not in Firefox if window is not created by JavaScript itself.

| improve this answer | |
  • yeah javascript is only supposed to be allowed to close windows opened by javascript. It is able to do it even if they weren't in some browsers but not all. – Phil B Feb 11 '14 at 15:34
0

Make sure you specify the name on both windows. If they share the same name, then when you open one with the same name it will replace it.

apex:commandButton value="Search Again" onclick="window.open('/apex/customreport', 'myexample');" />
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.