Right now I have a custom vf page on my details, that contains two related lists (Activity Histories and Open Activities) in two different tabs. The problem is that when I click a link, it opens a new window inside that section. I would like to open in a new window. Here is my VF Page (with script that I tried to put working):
<apex:page standardController="Account" extensions="ActivitiesAndHistoryRelatedListExtension">
<apex:tabPanel switchType="client" selectedTab="name1" id="theTabPanel" style="height:300px">
<apex:tab label="Atividades abertas" name="name1" id="tabOne">
<apex:outputPanel layout="block" style="overflow:auto;width:100%;height:150px;">
<apex:relatedList subject="{!account}" list="OpenActivities" >
<apex:facet name="header"> <apex:outputText value=""/></apex:facet>
</apex:relatedList>
</apex:outputPanel>
</apex:tab>
<apex:tab label="Histórico de atividades" name="name2" id="tabTwo">
<apex:outputPanel layout="block" style="overflow:auto;width:100%;height:150px;">
<apex:relatedList subject="{!account}" list="ActivityHistories" >
<apex:facet name="header"> <apex:outputText value=""/></apex:facet>
</apex:relatedList>
</apex:outputPanel>
</apex:tab>
</apex:tabPanel>
<script type="text/javascript">
$(document).ready(function() {
$("a[href^=http]").each(function(){
for(i=0; i<excludes.length; i++) {
if(this.href.indexOf(excludes[i]) != -1) {
return true; // continue each() with next link
}
}
if(this.href.indexOf(location.hostname) == -1) {
// attach a do-nothing event handler to ensure we can 'trigger' a click on this link
$(this).click(function() { return true; });
$(this).attr({
target: "_blank",
title: "Opens in a new window"
});
$(this).click(); // trigger it
} }) });
</script >
</apex:page>
But no matter what I do, it always open inside the section, like the example:
Anyone have any ideia how to fix this?
Best Answer
1) I do not see jquery being loaded in your vf page include the below line
2) If you want to open link in a different window all you need to look for all a tags and set attribute to blank (
NOTE: You can adjust the href that needs to be redirected based on your need, I have set the code to redirect all hrefs to a new window.