urlExists(u)
Last updated January 3, 2006
Version: 1 | Requires: ColdFusion MX | Library: NetLib
Description:
Checks to see if a particular URL actually exists.
Return Values:
Returns a boolean.
Example:
<cfloop index="u" list="#list#">
<cfoutput>Does #u# exist? #urlExists(u)#<br /></cfoutput>
</cfloop>
Parameters:
| Name | Description | Required |
|---|---|---|
| u | The URL to check. | Yes |
Full UDF Source:
<!---
Checks to see if a particular URL actually exists.
Gus made some changes to handle a unresolving domain.
@param u The URL to check. (Required)
@return Returns a boolean.
@author Ben Forta (ben@forta.com)
@version 1, January 3, 2006
--->
<cffunction name="urlExists" output="no" returntype="boolean">
<!--- Accepts a URL --->
<cfargument name="u" type="string" required="yes">
<!--- Initialize result --->
<cfset var result=true>
<!--- Attempt to retrieve the URL --->
<cfhttp url="#arguments.u#" resolveurl="no" throwonerror="no" />
<!--- Check That a Status Code is Returned --->
<cfif isDefined("cfhttp.responseheader.status_code")>
<cfif cfhttp.responseheader.status_code EQ "404">
<!--- If 404, return FALSE --->
<cfset result=false>
</cfif>
<cfelse>
<!--- No Status Code Returned --->
<cfset result=false>
</cfif>
<cfreturn result>
</cffunction>
Search CFLib.org
Latest Additions
Shawn Porter added
DeMoronize
2 hour(s) ago
Chris Carey added
readPropertiesFi...
1 day(s) ago
Randy Johnson added
lastDayofWeek
3 day(s) ago
Frank Marion added
sitemapPing
7 day(s) ago
Top Rated
QuickSort
Rated 5.0, 3 time(s)
indentXml
Rated 5.0, 3 time(s)
queryColumnsToSt...
Rated 5.0, 3 time(s)
generateSsccAsn
Rated 5.0, 3 time(s)