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 = – Ilya Lepesh Jul 15 '16 at 16:03

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'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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