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
UmapenUmapen 

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;
}

 

yuyinchayuyincha

i think commandbutton cant user target attribute.

 

you can do it like this.

 

<apex:commandButton onclick="openWin('http://www.baidu.com')" 

 <script>

function openWin(url){

 window.open(url);

</script> 

Ilya IvanovskiyIlya Ivanovskiy
<apex:commandLink target="_blank"
styleClass="btn"
style="text-decoration:none;padding:4px;" 
action="{!URLFOR($Action.Contact.NewContact)}" 
value="Create New Contact" />
Create New Contact (Salesforce button target _blank)