[SalesForce] Redirecting to external site from the value from url field

I am fetching the value of wesite field from account i want to redirect to site when user clicks on the link.
But am not redirected to the external url instead of that salesforce is appending its org url in fron of
eg: https://dev-pretestorg.force.com/www.google.com.

I also tried to use anchor tag and both are working in the same way.
I also tried with java script its also not redirecting to external site.
Can any one suggest me how to redirect to external site.

Best Answer

Salesforce stores the website value as an address only, without the protocol. When it outputs the value as an <apex:outputField /> it builds the link including protocol. You will need to add the protocol yourself as you are building the link yourself. I assume the reason you are building your own link is to get the target="_blank". So you can do:

<a href="http://{!item.Website}" target="_blank" >{!item.Website}</a>

or

<apex:outputLink value="http://{!item.Website}" target="_blank" >{!item.Website}</apex:outputLink>
Related Topic