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

commandButton target="_blank"

I am getting the following error when I use target"_blank" with commanButton.


Error: Unsupported attribute target in <apex:commandButton> at line 28 


Any suggestions on what are the alternatives to this. I do understand from the documentation that 

this option is available for commandlink.


I tried navigatetoURL (but do not want to hardcode ID)


onclick="navigateToUrl('/apex/myapexpage?id=001T0000008ylRf');" /></td>

function navigateToUrl(url) {
window.location = url;



i think commandbutton cant user target attribute.


you can do it like this.


<apex:commandButton onclick="openWin('')" 


function openWin(url){;


Ilya IvanovskiyIlya Ivanovskiy
<apex:commandLink target="_blank"
value="Create New Contact" />
Create New Contact (Salesforce button target _blank)