Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking to a place in the same page

Status
Not open for further replies.

philcha

Programmer
May 10, 2000
109
GB
How can I put into a CF-generated page a link to some other place in the same page?

It's easy in HTML - A HREF="#section_A" and A NAME="section_A".

But when I tried this in CF with
CFOUTPUT
A HREF="##section_A"
/CFOUTPUT
it didn't work - the browser simply reloaded the page.
 
I just put this code by itself on a CF page and it worked just fine.

<CFOUTPUT>
<A NAME=&quot;top&quot;/>
<A HREF=&quot;##bottom&quot;>Go to the Bottom</A>

[COLOR=666666]<!--- Create some space between top and bottom --->[/color]
#RepeatString(&quot;<BR>&quot;, 200)#

<A NAME=&quot;bottom&quot;/>
<A HREF=&quot;##top&quot;>Go to the Top</A>
</CFOUTPUT> - tleish
 
tleish,

I tried what you suggested and the result was that the for each such link the status bar showed
directory_name/#
instead of
directory_name/page.cfm#
When I checked the generated HTML using View Source, it looked OK:
<a href=&quot;#target_name&quot; title=&quot;Title text&quot;>

I tried this both with IE5 and Netscape 4, and got the same result in both cases.

For what it's worth, my development set-up is:
CF 4.0.1
Win 98 Second Edition
PWS

Anyone got any ideas what the problems is?
 
Yes, if you the url is
http:/..../directory_name/

The is will put

http:/..../directory_name/#anchorname

...but the achor should still work. I've tested this in both IE and Netscape, and the anchors work fine.

Am I missing the question? - tleish
 
In my frustration I didn't spell out what I was getting as accurately as I should have.

Page URL: http:/..../directory_name/page.cfm
Browser's address bar: http:/..../directory_name/page.cfm
Coding in page:
<cfoutput> .. <a href=&quot;##anchor_name&quot; title=&quot; .. &quot;> .. </a> .. </cfoutput>
Shown in status bar on mouseover:
http:/..../directory_name/#anchor_name
instead of http:/..../directory_name/page.cfm#anchor_name

Generated HTML:
<a href=&quot;#anchor_name&quot; title=&quot; .. &quot;> .. </a>

When I click the link, the browser gets the directory's index.htm, which re-directs to the home page. If I had no index.htm, I suspect I'd get a 404.

If the worst comes to the worst, I may have found a work round - specify the link as
<a href=&quot;#GetFileFromPath(GetBaseTemplatePath)###anchor_name&quot;>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top