I'm using a script and windows.open function to go to a specific URL when a user click a button on the VFpage. Something is going wrong because after the click the same page is reloaded.


<script type="text/javascript">
 function goback()

Inside the retURL variable, there is the URL where I want to go, something like: https://eu6.salesforce.com/0015800000DuQWsAAN'


<apex:commandButton action="{!deleteContract}" value="Elimina Contratto e prodotti selezionati" immediate="true"  onclick= "goback()" />

How can I solve this problem?

  • try window.location.href = Commented Jul 15, 2016 at 16:03

1 Answer 1


If you are using controller then better to navigate from the controller method. Do not use javascript for this.

In the last line of the method write like this:

return (new ApexPages.StandardController (new SObject(Id='0015800000DuQWsAAN'))).view(); 

replace the SObject with the name of specific object for which your recordId is '0015800000DuQWsAAN'

You must log in to answer this question.

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