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
VijoVijo 

Redirect to a specific browser tab (chrome,firefox etc)

Hi All,

I am launching a VF page, from a button, in a detail page. I have opened this in a tab in a browser (chrome for instance.)

Is there a way to redirect my page to a specific tab in the browser , when a user clicks on the cancel button? or to the same browser for that matter?

I have tried a pageReference to /{!id}, but it just opens the record in the current window, and without the browser's menus etc all.

PS: I did search the community..but considering the volume.. needless to say..I lost track couple of times..

hence would appreciate any response on this. 

 

Thank you

Best Answer chosen by Admin (Salesforce Developers) 
Suresh RaghuramSuresh Raghuram

vijo

 

for cancel you no need  to write any pagereference but in case if you want to over ride it do is as follows

 

if u donot want to change the existing functionality

<apex:commandbutton action="cancel" value="cancel">

 

if u want to override the existing functionality

<apex:commandbutton action="{!cancelmethod}" value="cancel" immediate="true"/>

 

In the class

public pageReference cancelMethod(){

 

pageReference pageRef = pageReference("/tab URL") for example www.salesforce.com/003/oo1 copy bolded part of your tab

pageRef .setRedirect(true);

retrurn pageref;

}

 

If this answers your question make this as a solution

 

All Answers

Suresh RaghuramSuresh Raghuram

<apex:commandbutton value="window.open("/{!Id}"); name="cancel">

 

Itthis answers your question please make this as sioltuiton.

Suresh RaghuramSuresh Raghuram

it opens in a new window for opening in a new tab

 

<apex:commandbutton value="window.open("/{!Id}" , _blank); name="cancel"> 

this is for a browser tab.

VijoVijo

Hi Suree, thank you for responding.. I tried it,. It routes back to the browser, and opens a new tab in it!!!

The second solution opens a new browser window... both were good to know for me.

My actual need was to see that the user lands back to the same tab in browser from where he/she has actually launched the vf page. Do you know of any as such 'command'  in visualforce?

 

Suresh RaghuramSuresh Raghuram

vijo

 

for cancel you no need  to write any pagereference but in case if you want to over ride it do is as follows

 

if u donot want to change the existing functionality

<apex:commandbutton action="cancel" value="cancel">

 

if u want to override the existing functionality

<apex:commandbutton action="{!cancelmethod}" value="cancel" immediate="true"/>

 

In the class

public pageReference cancelMethod(){

 

pageReference pageRef = pageReference("/tab URL") for example www.salesforce.com/003/oo1 copy bolded part of your tab

pageRef .setRedirect(true);

retrurn pageref;

}

 

If this answers your question make this as a solution

 

This was selected as the best answer
VijoVijo

Hi thank you.. that would work...appreciate your patience with this issue.