+ Start a Discussion
Nagarjun TNagarjun T 

what is the commandlink action in visualforce to open new window

User-added image
Best Answer chosen by Nagarjun T
Om PrakashOm Prakash
Hi Nagarjun T,
Bellow code will work for you.
JavaScript: return false is added to avoid your page refresh while opening popup window.
<apex:page setup="false" sidebar="false" standardController="contact" recordSetVar="ContactList">
<apex:form >
<apex:commandButton value="New Contact" action="/apex/customcontacts"/>
<apex:pageBlock >    
    <apex:pageBlockTable value="{!Contactlist}" var="A"> 
            <apex:column headerValue="Contact Name"> 
            <apex:commandLink onclick = "JavaScript:window.open('/apex/customcontactsdetailedpage?id={!A.id}','ContactDetails','height=500, width=500'); return false;">
            {!A.Name}
            </apex:commandLink>
        </apex:column> 
    <apex:column value="{!A.ID}"/>
    <apex:column value="{!A.Phone}"/>
    <apex:column value="{!A.mailingcountry}"/>
    </apex:pageBlockTable> 
 </apex:pageBlock>           
 </apex:form>
 </apex:page>

 

All Answers

Om PrakashOm Prakash
Hi Nagarjun.
Please use target="_blank" for open new window
<apex:commandLink action="/apex/CustomContactsDetailedPage?id={!A.id}" target="_blank" > 
 {!A.Name} 
</apex:commandLink>

 
Vinod ChoudharyVinod Choudhary
Hi Nagarjun.

You can use the below code
 Popup:
<apex:commandLink value=" {!A.Name}" onclick="window.open('/ {!A.id}')"/> {!A.Name}  </apex:commandLink >


Or
In New Tab:
 
<apex:commandLink action="/apex/CustomContactsDetailedPage?id={!USE_YOUR_PARAMITERS_HERE}" target="_blank"> {!A.Name}  </apex:commandLink >


Thanks
Vinod
Nagarjun TNagarjun T
Hi All, Thanks for ur time @VinodChoudary and @OmPrakash
I need a command link to open the pop-up window here iam giving my code

<apex:page setup="false" sidebar="false" standardController="contact" recordSetVar="ContactList">
<apex:form >
    <apex:commandButton value="New Contact" action="/apex/customcontacts"/>
<apex:pageBlock >    
            <apex:pageBlockTable value="{!Contactlist}" var="A"> 
                    <apex:column headerValue="Contact Name"> 
                    <apex:commandLink action="/apex/customcontactsdetailedpage?id={!A.id}" target="_blank">
                    {!A.Name}
                    </apex:commandLink>
                </apex:column> 
            <apex:column value="{!A.ID}"/>
            <apex:column value="{!A.Phone}"/>
            <apex:column value="{!A.mailingcountry}"/>
            
            </apex:pageBlockTable> >
 </apex:pageBlock>           
            </apex:form>
  </apex:page>
Vinod ChoudharyVinod Choudhary

Use Below code:

<apex:page setup="false" sidebar="false" standardController="contact" recordSetVar="ContactList">
<apex:form >
    <apex:commandButton value="New Contact" action="/apex/customcontacts"/>
<apex:pageBlock >    
            <apex:pageBlockTable value="{!Contactlist}" var="A"> 
                    <apex:column headerValue="Contact Name"> 
                    
                    <apex:commandLink value="{!A.id}" onclick="window.open('/apex/customcontactsdetailedpage?id={!A.id}')"/> 
                        {!A.Name}  
                    </apex:commandLink >

                </apex:column> 
            <apex:column value="{!A.ID}"/>
            <apex:column value="{!A.Phone}"/>
            <apex:column value="{!A.mailingcountry}"/>
            
            </apex:pageBlockTable> >
 </apex:pageBlock>           
            </apex:form>
  </apex:page>

If you Need any help do let me know.

Thanks
Vinod
Nagarjun TNagarjun T
Hello @Vinod Choudhary Bro, it's opening in new tab i want open that link in new pop-up window brooo
Vinod ChoudharyVinod Choudhary

You need to use JS:

Use Below Code:
 

<apex:page setup="false" sidebar="false" standardController="contact" recordSetVar="ContactList">
<apex:form >
    <apex:commandButton value="New Contact" action="/apex/customcontacts"/>
<apex:pageBlock >    
            <apex:pageBlockTable value="{!Contactlist}" var="A"> 
                    <apex:column headerValue="Contact Name"> 
                    
                    <apex:commandLink value="{!A.id}" onclick="window.open('/apex/customcontactsdetailedpage?id={!A.id}')"/> 
                        {!A.Name}  
                    </apex:commandLink >

                </apex:column> 
            <apex:column value="{!A.ID}"/>
            <apex:column value="{!A.Phone}"/>
            <apex:column value="{!A.mailingcountry}"/>
            
            </apex:pageBlockTable> >
 </apex:pageBlock>           
            </apex:form>
 

<script language="javascript" type="text/javascript">

function popitup(url) {
    newwindow=window.open(url,'name','height=200,width=150');
    if (window.focus) {newwindow.focus()}
    return false;
}


</script>
  </apex:page>
 

 

Om PrakashOm Prakash
Hi Nagarjun T,
Bellow code will work for you.
JavaScript: return false is added to avoid your page refresh while opening popup window.
<apex:page setup="false" sidebar="false" standardController="contact" recordSetVar="ContactList">
<apex:form >
<apex:commandButton value="New Contact" action="/apex/customcontacts"/>
<apex:pageBlock >    
    <apex:pageBlockTable value="{!Contactlist}" var="A"> 
            <apex:column headerValue="Contact Name"> 
            <apex:commandLink onclick = "JavaScript:window.open('/apex/customcontactsdetailedpage?id={!A.id}','ContactDetails','height=500, width=500'); return false;">
            {!A.Name}
            </apex:commandLink>
        </apex:column> 
    <apex:column value="{!A.ID}"/>
    <apex:column value="{!A.Phone}"/>
    <apex:column value="{!A.mailingcountry}"/>
    </apex:pageBlockTable> 
 </apex:pageBlock>           
 </apex:form>
 </apex:page>

 
This was selected as the best answer
Nagarjun TNagarjun T
Thank u for ur time  @VarunChoudary and @OmPrakash