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
tantoniotantonio 

Visualforce button - how to open in existing page


Below button opens in a separate tab. Originally this is the functionality I wanted but now I need to change to have it open in the existing page. 

How can I do this?

<apex:column >
                   <apex:commandButton onclick="return window.open('{!obj.LoginURL__c}')" value="Login" >
                       <Apex:outputLink value="{!obj.LoginURL__c}"/>
                   </apex:commandbutton>
               </apex:column>
ForceComForceCom
Hi ,

Try this .
<apex:column >
                   <apex:commandButton onclick="return window.open('{!obj.LoginURL__c}')" value="Login" >
                       <apex:outputLink value="{!obj.LoginURL__c}"  target="_self" />
                   </apex:commandbutton>
               </apex:column>

I added target="_self" in the outputlink.

Thanks 
tantoniotantonio
I made the change you suggested but the link still opens in a separate tab. Any other thoughts?
Sagarika RoutSagarika Rout
try below code  :

<apex:commandButton onclick="return window.open('{!obj.LoginURL__c}','_top')" value="Login"/>

No need to use output link  here
tantoniotantonio
Thanks for the suggestion Sagarika,

I made the change you suggested and clicking the button only refreshed the existing page. It didn't bring me to the path that is contained in LoginURL__c unfortuantely.

VF didn't seem to recognize the '_top' target contained within the window.open command. I tried other things like adding target='_top' and that didn't work either.

Still haven't found the right way to this. Please any other suggestions are welcome. Thanks!