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
lapaullapaul 

How to open up a new web page on a new web browser

Hi,

Is there a way to open up a new web page on a new web browser? The following code will open up a new page but using the existing web browser. Please advice. Thanks.

 

PageReference pg = Page.Certificate;
           pg.setRedirect(true);
           return pg;

bob_buzzardbob_buzzard

If you want to open a new page, you have to do that browser side.   

 

I usually do this via javascript, using the window.open method attached to an onclick event of a button or link.

 

 

lapaullapaul

Thanks for the tips. But I want to be able to open a new browser using Apex code. I know how to do it in Visualforce. You have any sample codes in Apex?

 

thanks,

Paul

 

bob_buzzardbob_buzzard

You can't do it from apex code - all you can do there is return a page that the browser will display in the window that requested it.  This isn't an apex/visualforce restriction, its how browsers work.

 

The only way that you could control it from apex is to return a page that opens the new page when the browser renders it, but that doesn't sound like what you want to achieve.