+ 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