+ Start a Discussion

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


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;
           return pg;


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.




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?






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.