I do it with JavaScript in various places since it is an object that
contains everything you could ever want to know. Here is a simple example:
<script language="JavaScript" type="text/javascript">
function gethrefs() {
var hreftext;
for(i=0; i<document.links.length; i++){
hreftext = document.links[i].href;
document.write(hreftext + "<br>");
}
}
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<a href="http://www.microsoft.com">Microsoft</a>
<a href="http://www.allaire.com">Allaire</a>
<a href="http://www.fusebox.org">Fusebox</a>
<br>
<br>
<script>gethrefs();</script>
</body>
</html>
-----Original Message-----
From: Neil Clark [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 22, 2001 4:07 AM
To: Fusebox
Subject: href finding
Anyone have any ideas on this? I a page which trawls through a user defined
page and returns all of the hrefs within it. What I want to do however is
actually get the text (or image) of the href...
Basicall I want to get <a href="#">GET ME</a> get me text. Any ideas?
here is the code I have so far....
<!--- set it up as an App so we can do seshion management --->
<cfapplication name="HREFSearchApp" sessionmanagement="Yes"
setclientcookies="Yes" sessiontimeout="#createtimespan(0,0,15,0)#"
applicationtimeout="#createtimespan(0,0,15,0)#">
<!--- set the default attributes --->
<cfparam name="Attributes.address" default="Unknown"><!--- web page to http
to and store results --->
<cfparam name="Attributes.username" default=""><!--- Username to access http
page with [if needed] --->
<cfparam name="Attributes.password" default=""><!--- password to access http
page with [if needed] --->
<cfparam name="Attributes.port" default="80"> <!--- Port [if different from
default] --->
<cfset session.levels = 1> <!--- declare session default level... --->
<!--- cfhttp out to specified address, store result in a static
variable --->
<cfhttp url="#Attributes.address#" method="GET" port="#Attributes.port#"
username="#Attributes.username#" password="#Attributes.password#"
resolveurl="true">
<cfset httpResult = cfhttp.fileContent>
<cfset startTheHref = FindNoCase("<a href=""", httpResult, 1)><!--- find the
1st link [acts as a fail safe if there is only one....] --->
<cfif startTheHref IS 0>No Hyperlinks Found<cfexit></cfif><!--- show if no
hyperlinks are found on page --->
<cfset endTheHref = FindNoCase("</a>", httpResult, startTheHref)><!--- find
the end of the link --->
<cfset diff = evaluate(endTheHref - startTheHref)>
<cfset link = HtmlCodeFormat(Mid(httpResult, startTheHref, diff) & "</a>")>
<cfset setHardLinkStart = evaluate(startTheHref + 9)>
<cfset findHardLinkEnd = FindNoCase(""">", httpResult, startTheHref)>
<cfset hardLinkLen = evaluate(findHardLinkEnd - setHardLinkStart)>
<cfset hardLink = Mid(httpResult, setHardLinkStart, hardLinkLen)>
<ul>
<cfoutput><li><b><a href="#hardLink#">#hardLink#</a></b>#link#</cfoutput>
<cfloop condition="#startTheHref# IS NOT 0">
<cfset startTheHref = FindNoCase("<a href=""", httpResult, endTheHref)>
<cfif startTheHref IS 0><cfexit></cfif>
<cfset endTheHref = FindNoCase("</a>", httpResult, startTheHref)>
<cfset diff = evaluate(endTheHref - startTheHref)>
<cfset link = HtmlCodeFormat(Mid(httpResult, startTheHref, diff) & "</a>")>
<cfset setHardLinkStart = evaluate(startTheHref + 9)>
<cfset findHardLinkEnd = FindNoCase(""">", httpResult, startTheHref)>
<cfset hardLinkLen = evaluate(findHardLinkEnd - setHardLinkStart)>
<cfset hardLink = Mid(httpResult, setHardLinkStart, hardLinkLen)>
<cfoutput><li><b><a href="#hardLink#">#hardLink#</a></b>#link#</cfoutput>
</cfloop>
</ul>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists