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
hemant ranahemant rana 

on click of custom button vf page opens in new tab

Hi have made a vf page and a custom button on campaign members. when i click on the cutom button i had given the function of executing javascript.

window.open('https://c.cs8.visual.force.com/apex/Mobiles?id={!Campaign.Id}','','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=yes,location=yes,status=yes');

its opening the new window but i want to open it in new tab. Please help
Best Answer chosen by hemant rana
AshwaniAshwani
Hemant,

Try with this:

window.open('https://c.cs8.visual.force.com/apex/Mobiles?id={!Campaign.Id}','_blank');


All Answers

bob_buzzardbob_buzzard
You cannot control whether this opens a new window or tab, as that is decided by the browser preferences.  With default browser settings window.open will more often than not open a new page, and setting up a link like the following:

<a href="https://c.cs8.visual.force.com/apex/Mobiles?id={!Campaign.Id}" target="_blank">Click here</a>

will more often than not open a new tab.  However, this is not guaranteed, and each user can change their browser settings.
AshwaniAshwani
Hemant,

Try with this:

window.open('https://c.cs8.visual.force.com/apex/Mobiles?id={!Campaign.Id}','_blank');


This was selected as the best answer
hemant ranahemant rana
Thanks Summer it worked 
Bram RaatjesBram Raatjes
Is it possible to enforce loading the visualforce page within your existing tab? Currently running into the issue that opening a visualforce page on a Chrome Browser leads to an error (a new tab requesting sign in). Opening the same visualforce page from Edge, the page is opened in the same tab - no issues.