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
CushtyCushty 

Open Link in visualforce in new window, not within VF page

Hi,
I created a related list of Opportuinity Approval History, purely to remove the Submit for approval button.

Now this sits in the detail of the opportnuity page but when someone clicks on the Recall/Approve/Reject links it opens the page within the visualforce and not in a new window.
Does anyone know how I can open these links in a new tab or page
Thanks

Code:
<apex:page StandardController="Opportunity">
      <apex:relatedList list="ProcessSteps" ></apex:relatedList>
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script> 
<script>

 $(document).ready(function() {  
 $("input[name='piSubmit']").hide();
        }); 
 </script>
</apex:page>
Emmanuel Cruz BEmmanuel Cruz B
Hi Cushty,

You need to set target attributes on links and modify the onclick action in the input button. You can try with the following:
$(document).ready(function() {  
    $("input[name='piSubmit']").hide();
    $("div[id$='MyProcess']").find("a.actionLink").each(function(){
        $(this).attr('target','_blank');
    });
    var piRemoveJsAction = $("div[id$='MyProcess']").find("input[name='piRemove']").attr('onclick');
    var pattern = /http+[a-zA-Z0-9:.%?=&_\-\/]*/;
    var newJsAction = "window.open('"+piRemoveJsAction.match(pattern)+"', '_blank')";
    $("div[id$='MyProcess']").find("input[name='piRemove']").attr('onclick', newJsAction);
});

Hope this helps you.
Emmanuel Cruz