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
nimdharnimdhar 

action and onclick attributes on commandLink

Hi,
 
I have a pop up window which popups a visual force page. I am trying to close this popup and reload my original page when some action is done as follows

<script>
 function closeSearchWindow()
 {
    window.close();
 }
</script>
<apex:commandLink value="Attach" action="{!attach}"  onclick="closeSearchWindow();">
      <apex:param assignTo="{!myclient}" value="{!location.id}"/>
</apex:commandLink>

But this is not working. Is there any other way to do this.

Thanks,
Nimdhar


Message Edited by nimdhar on 04-29-2008 07:22 AM
Best Answer chosen by Admin (Salesforce Developers) 
TehNrdTehNrd
What about instead of onclick use oncomplete?

All Answers

nimdharnimdhar
Hi,

I am trying different ways but none is working. Can anyone please tell me whether having action attribute and onclick attribute on the commandLink doesn't work?

Thanks,
Nimdhar
TehNrdTehNrd
Give this a try. Be aware that it doesn't work if you have development mode turned on in your user settings:

Code:
<script type="text/javascript">
    function closeWindow(){
           opener.location.reload(); 
           window.close();
    }
</script> 

<apex:commandButton onclick="closeWindow()" value="Close Window" styleClass="btn"/>

 
example is commandButton but I assume commandLink would behave the same.

nimdharnimdhar
Hi,

I have both action and onclick attributes in my commandlink. I think that is the reason it is not working. But I don't know how to solve it. Clicking on my command link must call a action method in the controller and after it is executed the javascript function must execute and close the window.

Thanks,
Nimdhar
TehNrdTehNrd
What about instead of onclick use oncomplete?
This was selected as the best answer
nimdharnimdhar
Thank you I will try that.
nimdharnimdhar
Okay. Thank you for your help.
TehNrdTehNrd
Did oncomplete work?
nimdharnimdhar
yes it  did.
dchasmandchasman
When dev mode is enabled we actually contain the running page in an iframe and that will tend to interact with setting locations, closing windows, etc. I should be possible to make your code work in either case...
NS_ForceNS_Force
Hi,
 
I am facing the same problem.On click of a button I need to close the popup window.But here window.close is not working.
Did anyone got the solution? Pls help. 
Shwetal DesaiShwetal Desai
M not able to get opener on my pop up page...
even m not able to return value from pop up page to opener page.. using "window.returnValue"
please note both pop up and parent page are VF page.
 
any idea?
Jahnvi JasaniJahnvi Jasani
I have the same thing to do as I have a pop up window which popups a visual force page. I am trying to close this popup and reload my original page when some action is done.

By using oncomplete attribute in commandlink I can close the pop up but the original page does not reload automatically.

Can anyone please help.

Thanks