By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,666 Members | 1,544 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,666 IT Pros & Developers. It's quick & easy.

How to link to a location within another document?

P: n/a
I have web document A which contains six links that all go to document B.
However, all hyperlinks must go to a different location within that document
(similar to anchors: A NAME= etc.).

How do I achieve this? Any pointers are appreciated. Thanks!

Nov 23 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Yeah wrote:
I have web document A which contains six links that all go to document B.
However, all hyperlinks must go to a different location within that document
(similar to anchors: A NAME= etc.).

How do I achieve this? Any pointers are appreciated. Thanks!


How about something like:

http://example.com/documentb.html#name3

The "name3" place needs to be an <a name="name3"></a> of course.

--
-bts
-Warning: I brake for lawn deer
Nov 23 '05 #2

P: n/a
On Sat, 12 Nov 2005 20:26:19 GMT, Beauregard T. Shagnasty wrote:
Yeah wrote:
I have web document A which contains six links that all go to document B.
However, all hyperlinks must go to a different location within that document
(similar to anchors: A NAME= etc.).

How do I achieve this? Any pointers are appreciated. Thanks!


How about something like:

http://example.com/documentb.html#name3

The "name3" place needs to be an <a name="name3"></a> of course.


Wouldn't using id="name3" on an appropriate element be the more modern way
to do this? I didn't see the original post, but from what you've quoted it
sounds like the original poster wanted to use something other than <a
name="name3"> (hence the phrase "similar to anchors: A NAME=").

--
Safalra (Stephen Morley)
http://www.safalra.com/hypertext/
Nov 23 '05 #3

P: n/a
Safalra wrote:
On Sat, 12 Nov 2005 20:26:19 GMT, Beauregard T. Shagnasty wrote:
Yeah wrote:
I have web document A which contains six links that all go to document B.
However, all hyperlinks must go to a different location within that document
(similar to anchors: A NAME= etc.).

How do I achieve this? Any pointers are appreciated. Thanks!
How about something like:

http://example.com/documentb.html#name3

The "name3" place needs to be an <a name="name3"></a> of course.


Wouldn't using id="name3" on an appropriate element be the more modern way
to do this?


Yes, it would. <g> I've been doing home repairs today, and it's an old
house.

How about: The "name3" place needs to be an <a id="name3"></a>
I didn't see the original post, but from what you've quoted it
I quoted the entire original post. It was short, so I even didn't trim
it from this reply.
sounds like the original poster wanted to use something other than <a
name="name3"> (hence the phrase "similar to anchors: A NAME=").


--
-bts
-Warning: I brake for lawn deer
Nov 23 '05 #4

P: n/a
Safalra a écrit :
On Sat, 12 Nov 2005 20:26:19 GMT, Beauregard T. Shagnasty wrote:
Yeah wrote:
I have web document A which contains six links that all go to document B.
However, all hyperlinks must go to a different location within that document
(similar to anchors: A NAME= etc.).

How do I achieve this? Any pointers are appreciated. Thanks!


How about something like:

http://example.com/documentb.html#name3

The "name3" place needs to be an <a name="name3"></a> of course.

Wouldn't using id="name3" on an appropriate element be the more modern way
to do this? I didn't see the original post, but from what you've quoted it
sounds like the original poster wanted to use something other than <a
name="name3"> (hence the phrase "similar to anchors: A NAME=").


Some HTML 4.01 compliant browsers and applications do not support
anchors defined by id.

"Use id or name?"
http://www.w3.org/TR/REC-html40/stru...l#idx-anchor-9

Gérard
--
remove blah to email me
Nov 23 '05 #5

P: n/a
On Sat, 12 Nov 2005 17:09:31 -0500, Gérard Talbot
<ne***********@gtalbot.org> wrote:
Safalra a écrit :

Wouldn't using id="name3" on an appropriate element be the more modern way
to do this? I didn't see the original post, but from what you've quoted it
sounds like the original poster wanted to use something other than <a
name="name3"> (hence the phrase "similar to anchors: A NAME=").


Some HTML 4.01 compliant browsers and applications do not support
anchors defined by id.

"Use id or name?"
http://www.w3.org/TR/REC-html40/stru...l#idx-anchor-9


Well, Netscape 4 doesn't support id. It's a bit of a stretch to call
Netscape 4 (any incarnation) HTML 4.01 compliant. And doubtful whether
it's worth worrying about any more (users can after all always get to
the link destinations, but they have to do their own scrolling). All
more recent browsers that I've heard of support id.

The only tool I've met that couldn't cope with id is the Xenu
link-checking tool. There may be others.

--
Stephen Poley

http://www.xs4all.nl/~sbpoley/webmatters/
Nov 23 '05 #6

P: n/a
Stephen Poley <sb******************@xs4all.nl> wrote:
The only tool I've met that couldn't cope with id is the Xenu
link-checking tool. There may be others.


Xenu can't handle <a href="#bar">bar</a> links containing only the
fragment identifier, but it works fine if you include the file name <a
href="foo.htm#bar">bar</a>.

--
Spartanicus
Nov 23 '05 #7

P: n/a
In article <un********************************@4ax.com>,
Stephen Poley <sb******************@xs4all.nl> wrote:
On Sat, 12 Nov 2005 17:09:31 -0500, Gérard Talbot
<ne***********@gtalbot.org> wrote:
Some HTML 4.01 compliant browsers and applications do not support
anchors defined by id.

"Use id or name?"
http://www.w3.org/TR/REC-html40/stru...l#idx-anchor-9


Well, Netscape 4 doesn't support id. It's a bit of a stretch to call
Netscape 4 (any incarnation) HTML 4.01 compliant. And doubtful whether
it's worth worrying about any more (users can after all always get to
the link destinations, but they have to do their own scrolling). All
more recent browsers that I've heard of support id.

The only tool I've met that couldn't cope with id is the Xenu
link-checking tool. There may be others.


I had also wanted to ask about use of name and id for anchor.

I thought I saw indications elsewhere that that for xhtml the use of
name was either considered deprecated or was likely to become so (but
now I can't find that reference again). I thought I even saw a
suggestion that name might be dropped as an anchor in future xhtml
versions.

While I have decided to write all my pages in HTML 4.01 Strict, I did
want to keep my pages as easy to convert to a future XHTML as I could,
just in case.

<h2 id="foo"><a name="foo">Subhead</a> goes here</h2>
is a variation I have seen suggested as a way of still supporting old
browsers. Since both id and name point to the same anchor, using the
same tag in their shared namespace should be allowed. At least, I think
it should be allowed. I gather this validates in xhtml.

Plus if I do some automated conversion of older pages, the addition of
id to the tag preceding an existing name anchor seems less likely to
accidentally break things if I get the search and replace wrong.
Because about 80 of my pages relate to very old Psion PDAs, I need to
avoid breaking Opera v3 and Opera v5, as released for Psion, as well as
support browsers running on mobile phones.

However what do people think of that method of doing anchors?

--
http://www.ericlindsay.com
Nov 23 '05 #8

P: n/a

On Tue, 15 Nov 2005, Eric Lindsay wrote:

[...]
<h2 id="foo"><a name="foo">Subhead</a> goes here</h2>
is a variation I have seen suggested as a way of still supporting old
browsers.
Fine.
Since both id and name point to the same anchor, using the
same tag in their shared namespace should be allowed. At least, I think
it should be allowed. I gather this validates in xhtml.
You "gather"? Shouldn't be hard to verify that! But as long as
you're aiming at older browsers, I don't see the relevance of XHTML.
Keep an eye on the future, of course; but stay with HTML (strict, by
all means[1]) unless/until you have a compelling reason to move.

And it shouldn't be hard to filter out the <a name=...> markup in
converting to some future version where it had been made invalid.
However what do people think of that method of doing anchors?


I don't see anything against it as a principle. It is, after all,
making use of a deliberate W3C compatibility policy. If, as you say,
you have a particular catchment of older browsers, then it makes good
sense IMHO.

When doing CSS, though, if you want things like a:hover to only take
effect for links, and not for anchors, take care to use the specific
selectors (a:link:hover, a:visited:hover etc.).

good luck

[1] This doesn't seem to apply in your case, but when I see how many
lemmings have migrated from HTML Transitional to XHTML/1.0
Transitional, I'm convinced they are missing the key point. The
important move is from Transitional to Strict.
Nov 23 '05 #9

P: n/a
In article <Pine.WNT.4.64.0511150038300.388@ZORIN>,
"Alan J. Flavell" <fl*****@physics.gla.ac.uk> wrote:
On Tue, 15 Nov 2005, Eric Lindsay wrote:
<h2 id="foo"><a name="foo">Subhead</a> goes here</h2>
I gather this validates in xhtml.
You "gather"? Shouldn't be hard to verify that! But as long as
you're aiming at older browsers, I don't see the relevance of XHTML.
Keep an eye on the future, of course; but stay with HTML (strict, by
all means[1]) unless/until you have a compelling reason to move.


It is only a proportion of my pages (the ones about Psion PDAs) that are
aimed at people who may view them with really obsolete browsers. Other
pages could be in either HTML or XHTML, although I have used and intend
to keep using HTML 4.01 Strict. XML enthusiasts keep telling me of the
wonders and advantages of XML, and all the tools that will be available
to do handy things with it. So being at least partly prepared to move
(perhaps involving converting old pages to XHTML) seems reasonable, if
the advantages ever seem overwhelming, and all the tools are present.
So far I have found it confusing rather than helpful.
[1] This doesn't seem to apply in your case, but when I see how many
lemmings have migrated from HTML Transitional to XHTML/1.0
Transitional, I'm convinced they are missing the key point. The
important move is from Transitional to Strict.


I became convinced that the important migration was to Strict rather
than Transitional, rather than HTML to XHTML some time ago. However
there seems so many conflicting opinions on the web about which
direction to take that mostly I end up confused. This is not helped by
the majority path not always seeming to be the best one.

Hence I ask simple questions here, and then try to ensure I understand
the ramifications of the answer.

--
http://www.ericlindsay.com
Nov 23 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.