+ Start a Discussion

Displaying of Visualforce Page in a new Window

Do any expert know how to display a Visualforce Page in a new separated Window when clicking from a button of the current page?
Best regards!
The easiest way to do this is when the VF page uses a standard controller or controller extension. If so, then just create a new custom button and set the Behavior to "Display new window" and redirect it to a Visualforce page.

If the VF page uses a custom controller, then you might have to create an scontrol that simply does the redirect to the VF page url. And then create a custom button to open a new window for the SControl.

Thanks aalbert, but in my case, I want to create a new separated Window for a new Visualforce Page from the apex:commandButton of the current Visualforce Page.
I see that the <apex:commandLink> attributes support setting the "target" which can open up a new window. And also set the action attribute to the controller's method which redirect to a new Visualforce page:

VF Page snippet:
<apex:commandLink action="{!reDirect}" target="_blank" value="Save" id="theButton"/>

Apex Class snippet:

public PageReference reDirect() {
   PageReference pageRef = new PageReference('http://www.google.com');
   return pageRef;       


I don't see the target attribute available for the <apex:commandButton>.

I had the same situation, using JavaScript is easier but in my experience you have to manage the page state yourself. Apex:CommandLink has the target="_blank" support. But it will appear as link. You can use little CSS to make commandLink appear as button while opening the URL in new window.


<style type="text/css">
a.linkAsBtn:hover {
text-decoration: none;
padding: 3px 6px;


<apex:commandLink value="Do Something" action="{!doSomething}" target="_blank" styleClass="btn linkAsBtn"/>


Where doSomething is a action function in controller which returns page reference.