4

I'm trying to avoid https://na32.visual.force.com/apex/vfpage that is being added to the website that is already stored in field carrier_website__c. carrier_website__c has values like the following:

  1. https://www.google.com

  2. http://google.com

  3. www.google.com

This is how I tried:

    <apex:outputLink value="/{!q.Shipment_Number__r.carrier_website__c}" target="">
           <apex:outputText value="{!q.Shipment_Number__r.carrier_website__c}"/>
    </apex:outputLink>

I have tried with double quotes, double forward slash. I have also tried to use javascript window.location, but I face the same problem as discussed above. Any suggestions? Thanks.

EDIT: But if I remove the "/" in outputLink value, then the salesforce instance gets added like this.... abc.my.salesforce.com/www.carrierwebsite.com –

1 Answer 1

5

Your issue is the / in the output link. That appends the URL to what you are entering. change to

<apex:outputLink value="{!q.Shipment_Number__r.carrier_website__c}" target="">
           <apex:outputText value="{!q.Shipment_Number__r.carrier_website__c}"/>
    </apex:outputLink>
8
  • 1
    The reason why / is an issue is that a leading / automatically causes the browser to assume the scheme and authority of the current page.
    – sfdcfox
    Commented Dec 10, 2014 at 17:59
  • Thanks for your reply. But if I remove the "/" then the salesforce instance gets added like this.... abc.my.salesforce.com/www.carrierwebsite.com
    – MnZ
    Commented Dec 10, 2014 at 18:48
  • 1
    @MnZ - Does your URL stored in the field start with http(s)://something. If not try with a field that does (i.e. add http:// to the carrierwebsite)
    – Eric
    Commented Dec 11, 2014 at 13:24
  • Hi Eric, the URL custom field has the following format https://, http: and www.
    – MnZ
    Commented Dec 11, 2014 at 13:40
  • 1
    @MnZ - That is the behavior of salesforce. You will need to check and see if the field starts with HTTP:// and if not add it in the formula. Otherwise salesforce will treat it as a relative URL
    – Eric
    Commented Dec 11, 2014 at 21:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .