0

I am using a field Link__c which is a formula field returning a hyperlink . I need this hyperlink to be used in my visualforce page . What I am doing is below

  <apex:pageblockSection >
  <apex:panelGrid style="font-weight:bold;font-size: 13px;" >
  <apex:outputlink value="{!Opportunity.Link__c}" >Link to Information</apex:outputlink>
  </apex:panelGrid>
  </apex:pageblockSection>

But dont know why a instance URL is getting prefixed to the URL in Link__c field .This URL is getting prefixed https://Is--dev2--a.456.visual.force.com/apex/%3Ca+href=%22https:

0

It's because the link is already HTML, so the href thinks it's a relative URL because it does not immediately start with a protocol, such as https or ftp.

Imagine your output in a normal HTML link:

<a href="&lt;a href=&quot;https://...&quot;">

Obviously, this isn't what you meant. You want a link. You can either use apex:outputField or apex:outputText:

<apex:outputField value="{!Opportunity.Link__c}" />

<apex:outputText escape="false" value="{!Opportunity.Link__c}" />

Note that because it's already a link, you can't directly modify the text of the link, because it's "baked in" to the HTML. You could probably use SUBSTITUTE to fix that if you wanted to, though:

<apex:outputText escape="false" value="{!SUBSTITUTE(Opportunity.Link__c,'>Original Link Text<','>Click for Information<')}" />
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.