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
Dipa87Dipa87 

How to open a page in another tab using pageReference?

Hi ,

 

Can you please tell me-how to open a page in another tab using page reference?

 

Thanks in advance.

AshishyadavAshishyadav
Hi,



Try the below code:

/////////////////////// VF Pages ////////////////////////////////

<apex:page sidebar="false" standardStylesheets="false" controller="LinkController">



<apex:outputPanel styleClass="app-icon" layout="block" id="app">

<apex:form >

<apex:commandLink action="{!Save}" reRender="app" value="rediff" onclick="WindowNew()">

&lt;script&gt;

function WindowNew()

{

alert('abc');

window.open('http://www.rediff.com/');

}

&lt;/script&gt;

</apex:commandLink>

</apex:form>

</apex:outputPanel>



</apex:page>

/////////////// Controller /////////////////////////

public class LinkController {



public PageReference Save()



{



String newPageUrl = 'http://www.rediff.com/';



return null;



}

}



check this out see if it helps for you
AshishyadavAshishyadav
this is for if you want to open in new window

public PageReference CancelTicket()
{
pageReference ref = new PageReference(‘/apex/PageName’);
ref.setRedirect(true);
return ref;
}



Where PageName= name of the page which you want to create and open




give kudos if it helps