CFLib.org – Common Function Library Project

EmailDomainLink(theEmailAddress[, theTarget])

Last updated September 29, 2003

author

Shawn Seley

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Formats specified e-mail address so that its domain is a link to its www.domain.com web site. Helpful when analyzing where your subscribers come from.

Return Values:
Returns a string.

Example:

<cfoutput>
EmailDomainLink("admin@cflib.org"):<br>
#EmailDomainLink("admin@cflib.org")#<br>
<br>
EmailDomainLink("shawnse@aol.com", "_blank"):<br>
#EmailDomainLink("shawnse@aol.com", "_blank")#<br>
</cfoutput>

Parameters:

Name Description Required
theEmailAddress Email address. Yes
theTarget Optional target for new window. No

Full UDF Source:

/**
 * Formats an e-mail address so that its domain is a link to its web site.
 * 
 * @param theEmailAddress      Email address. (Required)
 * @param theTarget      Optional target for new window. (Optional)
 * @return Returns a string. 
 * @author Shawn Seley (shawnse@aol.com) 
 * @version 1, September 29, 2003 
 */
function emailDomainLink(theEmailAddress) {
    var this_username  = listFirst(theEmailAddress, "@");
    var this_domain    = listLast(theEmailAddress, "@");
    var theTarget      = "";
    if(arrayLen(arguments) gte 2) theTarget = arguments[2];
    if(Len(theTarget) GT 0) return "#this_username#@<a href=""http://www.#this_domain#"" target=""#theTarget#"">#this_domain#</a>";
    else return "#this_username#@<a href=""http://www.#this_domain#"">#this_domain#</a>";
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson