CFLib.org – Common Function Library Project

GetAnchorFromURL(this_url)

Last updated February 21, 2002

author

Shawn Seley

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Returns the page anchor for the supplied URL. If no anchor is found, then returns an empty string. Works with the http protocol where page anchors follow the "filename#anchor" syntax.

Return Values:
Returns a string.

Example:

<cfoutput>
#GetAnchorFromURL("http://somehost.com/dir1/dir2/filename.htm##anchor")#<br>
#GetAnchorFromURL("filename.htm##anchor")#<br>
#GetAnchorFromURL("filename.htm##")#<br>
#GetAnchorFromURL("filename.htm")#<br>
#GetAnchorFromURL("../filename.htm##anchor")#<br>
</cfoutput>

Parameters:

Name Description Required
this_url URL to parse. Yes

Full UDF Source:

/**
 * Returns the page anchor from a specified URL.
 * 
 * @param this_url 	 URL to parse. 
 * @return Returns a string. 
 * @author Shawn Seley (shawnse@aol.com) 
 * @version 1, February 21, 2002 
 */
function GetAnchorFromURL(this_url) {
	var re_found_struct = "";
	
	this_url = trim(this_url);
	
	re_found_struct = REFind("##[^\?]*", this_url, 1, "True");
	
	if (re_found_struct.pos[1] GT 0) {
		return Mid(this_url, re_found_struct.pos[1]+1, re_found_struct.len[1]-1);
	} else return "";
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson