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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Link to a page,but 'land' on a specific section of that page?

Status
Not open for further replies.

LucyL

Technical User
Feb 20, 2002
113
0
0
US
Hi,
Is it possible to link to a page and land on a specific section of that page? Can I use an anchor and if so, do I put the anchor in the href of the page that links to the new page??

This is my href that calls my new page
<a href="details.htm" target = "content">

Thank you.
 
Code:
<a href="details.htm[COLOR=red]#section1[/color]">Go to section one</a>
Code:
<h1 [COLOR=red]id="section1"[/color]>Section One</h1>
<p>Lorem ipsum dolor sit amet...</p>
[ul][li]each id must be unique: you can't use the same id twice on a page[/li]
[li]an id must not begin with a number (e.g. id="1")[/li][/ul]

<marc> i wonder what will happen if i press this...[ul][li]please tell us if our suggestion has helped[/li][li]need some help? faq581-3339[/li][/ul]
 
I'm having a problem with this type of link. I'm developing in HTML Kit and when I set up the code to link to a section in another page it works fine in Gecko mode but not in internet explorer. IE tells me that it can't find the page.
 
What does your link look like? Could you post that code? Incidentally, you would get more people involved if you'd started a new thread.
 
<a
href="PuritanBackground.shtml">Early Puritan Beginnings</a></li><li><a
href="PuritanBackground.shtml#section2">Puritans in England</a></li><li><a
href="PuritanBackground.shtml#section3">Massachusetts Bay Colony</a></li>
Then in the PuritanBackground page, first I tried this:

<h2 id="Section2">Puritans in England</h2>
blah blah
<h2 id="Section3">Massachusetts Bay Colony</h2>
blah blah

then :

<p><a id="section2"></a>
<h2>Puritans in England</h2>
blah blah
</p><p>
<a id="section3"></a>
<h2>Massachusetts Bay Colony</h2>
blah blah
</p>

Both ways worked in Gecko mode and not in IE
 
Unfortunately, IE is a little deprecated as well. ID is correct way to do it in future browsers but right now you should support the old ones as well and use
Code:
<a name="section2" id="section2"></a>
for best results.
 
I've never had this kind of problems. Although IE usually is not fussing about this, are you using the same capitalization in both link and anchor? That could mess-up the functionality, since ids should be case sensitive. Anything else... do you have a working example of this on the web?
 
This code works fine for me in IE6/FF:

Code:
<html>
<head>
</head>

<body>
<ul id="top">
	<li><a href="#section1">Section 1</a></li>
	<li><a href="#section2">Section 2</a></li>
	<li><a href="#section3">Section 3</a></li>
</ul>

<h3 id="section1">Section 1</h3>
<p><a href="#top">Back to top</a></p>
<p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> 
<p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> 
<p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p>

<h3 id="section2">Section 2</h3>
<p><a href="#top">Back to top</a></p>
<p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> 
<p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> 
<p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p>

<h3 id="section3">Section 3</h3>
<p><a href="#top">Back to top</a></p>
<p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> 
<p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> 
<p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p> <p>blah...</p>

</body>
</html>

--James
 
It could be because I'm on my own pc, so I'll put it on my hosting server and see what happens. Problem is the site is nowhere near finished.
 
I put it online: I seems to be working. It must be a glitch in how I have my development set up. A lot of the links you will see go to an old site or blank pages, this is a re-development and i've only gotten as far as the first links.
Thanks all
gl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top