473,326 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Why does named anchor fail on first reference?

I have a long page with several sections and want to link to these sections from
another page like this:

<a href='http://www.mysite.com/content.html#section12'>Section 12</a>

Here's what the anchor looks like in content.html:

<h2 id="section12"><a href=http://www.mysite.com/index.html
target="_self">Return to Table of Contents</a></h2>

If I clear my browser's cache and click on the Section 12 link in index.html, I
do not go to the correct position in content.html. But If I go back to
index.html and try again, the link will (on subsequent attempts) take me to the
correct position.

This behavior is consistent in FF and IE.

I've also tried using a stand-alone anchor like this:

<a name="section12">

Same results.

Am I missing something? Is there some trick to getting a named anchor to work
the first time?

Thanks in advance.
Jul 6 '06 #1
12 2109
Els
deko wrote:
I have a long page with several sections and want to link to these sections from
another page like this:

<a href='http://www.mysite.com/content.html#section12'>Section 12</a>

Here's what the anchor looks like in content.html:

<h2 id="section12"><a href=http://www.mysite.com/index.html
target="_self">Return to Table of Contents</a></h2>

If I clear my browser's cache and click on the Section 12 link in index.html, I
do not go to the correct position in content.html. But If I go back to
index.html and try again, the link will (on subsequent attempts) take me to the
correct position.

This behavior is consistent in FF and IE.

I've also tried using a stand-alone anchor like this:

<a name="section12">

Same results.

Am I missing something? Is there some trick to getting a named anchor to work
the first time?
I think the page is too long, or has too many images and stuff to be
loaded? I've seen it happen too, and I'm just guessing that the
browser finds the ID before all the content that preceeds it is loaded
into the browser.

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
Jul 6 '06 #2
"deko" <de**@nospam.comwrote:
>Am I missing something?
We are (an URL).

--
Spartanicus
Jul 6 '06 #3
browser finds the ID before all the content that preceeds it is loaded
into the browser.
That's something I considered - the page is dynamically generated with php and
does have some larger images.

While troubleshooting, I took the page source and made a static page out of it -
still had the same problem. Yet this is the only thing that makes any sense,
since, at that point, everything was generic HTML with simple anchors.

I think you may be correct. If so, this is browser bug. And both IE and FF
have it. A browser should be able to recognize an anchor in a URL, render the
page, then position itself accordingly.

Jul 6 '06 #4
>browser finds the ID before all the content that preceeds it is loaded
>into the browser.

That's something I considered - the page is dynamically generated with php and
does have some larger images.

While troubleshooting, I took the page source and made a static page out of
it - still had the same problem. Yet this is the only thing that makes any
sense, since, at that point, everything was generic HTML with simple anchors.

I think you may be correct. If so, this is browser bug. And both IE and FF
have it. A browser should be able to recognize an anchor in a URL, render the
page, then position itself accordingly.
I just loaded IE7 and tested with that - I could not duplicate the problem.
This is indeed a browser bug and the IE7 team squashed it. Let's hope the
Firefox folks catch on as well.

As an aside, IE is pretty speedy as far as page loading goes. I think I like
it. Too bad it breaks my ability to access my hotmail email account from
Outlook Express. Otherwise I might make it my default browser.

Jul 6 '06 #5
deko wrote:
I have a long page with several sections and want to link to these
sections from another page like this:

<a href='http://www.mysite.com/content.html#section12'>Section 12</a>

Here's what the anchor looks like in content.html:

<h2 id="section12"><a href=http://www.mysite.com/index.html
target="_self">Return to Table of Contents</a></h2>
Aside: are you sure that "Return to Table of Contents" is a second
level heading? Sounds more like a navigational aid that perhaps should
be a <divor at worst a <p>.

BTW, I looked at http://mysite.com/ but couldn't find your links. If you
are using that for an example, please use .. well .. example.com, which
is reserved for the purpose.

--
-bts
-Warning: I brake for lawn deer
Jul 6 '06 #6
Deciding to do something for the good of humanity, Els
<el*********@tiscali.nldeclared in
comp.infosystems.www.authoring.html:
browser finds the ID before all the content that preceeds it is loaded
into the browser.
I find that happens quite often with w3c.org - the HTML and CSS specs
for example.

--
Mark Parnell
My Usenet is improved; yours could be too:
http://blinkynet.net/comp/uip5.html
Jul 6 '06 #7
Els
Mark Parnell wrote:
Deciding to do something for the good of humanity, Els
<el*********@tiscali.nldeclared in
comp.infosystems.www.authoring.html:
>browser finds the ID before all the content that preceeds it is loaded
into the browser.

I find that happens quite often with w3c.org - the HTML and CSS specs
for example.
That's exactly where I've seen it before :-)

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
Jul 6 '06 #8
>>browser finds the ID before all the content that preceeds it is loaded
>>into the browser.

I find that happens quite often with w3c.org - the HTML and CSS specs
for example.

That's exactly where I've seen it before :-)
I discovered that if I remove all style directives and images the problem goes
away. Perhaps there's a CSS trick or work-around that will help...

Jul 7 '06 #9
Els
deko wrote:
>>>browser finds the ID before all the content that preceeds it is loaded
into the browser.

I find that happens quite often with w3c.org - the HTML and CSS specs
for example.

That's exactly where I've seen it before :-)

I discovered that if I remove all style directives and images the problem goes
away. Perhaps there's a CSS trick or work-around that will help...
Does the problem go away if you only take out the images and leave the
styles in?

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
Jul 7 '06 #10
>>>>browser finds the ID before all the content that preceeds it is loaded
>>>>into the browser.

I find that happens quite often with w3c.org - the HTML and CSS specs
for example.

That's exactly where I've seen it before :-)

I discovered that if I remove all style directives and images the problem
goes
away. Perhaps there's a CSS trick or work-around that will help...

Does the problem go away if you only take out the images and leave the
styles in?
Haven't tested that, but I did hear that images on either side of the anchor can
give the browser a case of acid reflux where the position scrolls back up for
some reason. If that's the case, then it's not a matter of the page not being
rendered before trying to find the anchor. Still, the browser should not barf
on something like this...

If I figure it out, I'll post back

Jul 7 '06 #11
Els
deko wrote:
>>>>>browser finds the ID before all the content that preceeds it is loaded
>into the browser.
>
I find that happens quite often with w3c.org - the HTML and CSS specs
for example.

That's exactly where I've seen it before :-)

I discovered that if I remove all style directives and images the problem
goes
away. Perhaps there's a CSS trick or work-around that will help...

Does the problem go away if you only take out the images and leave the
styles in?

Haven't tested that, but I did hear that images on either side of the anchor can
give the browser a case of acid reflux where the position scrolls back up for
some reason. If that's the case, then it's not a matter of the page not being
rendered before trying to find the anchor.
I think it is :-)
I think it depends on whether you set width and height for the images
in the HTML. Images load after the page usually, so yes, the text,
including the anchors, will have to be shifted to make room for the
images if room was not reserved for them right when the page was
loaded.
Still, the browser should not barf on something like this...

If I figure it out, I'll post back
If you'd give a URL, others could help figuring it out ;-)

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
Jul 7 '06 #12

"Els" <el*********@tiscali.nlwrote in message
news:iy******************************@40tude.net.. .
deko wrote:
>>>>>>browser finds the ID before all the content that preceeds it is loaded
>>into the browser.
>>
>I find that happens quite often with w3c.org - the HTML and CSS specs
>for example.
>
That's exactly where I've seen it before :-)

I discovered that if I remove all style directives and images the problem
goes
away. Perhaps there's a CSS trick or work-around that will help...

Does the problem go away if you only take out the images and leave the
styles in?

Haven't tested that, but I did hear that images on either side of the anchor
can
give the browser a case of acid reflux where the position scrolls back up for
some reason. If that's the case, then it's not a matter of the page not
being
rendered before trying to find the anchor.

I think it is :-)
I think it depends on whether you set width and height for the images
in the HTML. Images load after the page usually, so yes, the text,
including the anchors, will have to be shifted to make room for the
images if room was not reserved for them right when the page was
loaded.
>Still, the browser should not barf on something like this...

If I figure it out, I'll post back

If you'd give a URL, others could help figuring it out ;-)
500px of margin-bottom on the div containing the anchors seems to fix it. As if
there weren't enough CSS quirks, hacks and workarounds... welcome to web
development...

Jul 8 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: deko | last post by:
I use named anchors to take users to specific parts of a long page. But I want to add some processing and do some things with my nav bar when users go to certain sections delineated by named...
8
by: lawrence | last post by:
I'm learning Javascript. I downloaded a script for study. Please tell me how the variable "loop" can have scope in the first function when it is altered in the second function? It is not defined...
2
by: SammyBar | last post by:
Hi, I'm trying to bind a custom collection class to a data grid, following the guidelines from the article http://msdn.microsoft.com/msdnmag/issues/05/08/CollectionsandDataBinding/default.aspx....
6
by: clintonG | last post by:
Example: <a href="mailto:somebody@somewhere.com>Send Mail</a> I've been trying to find documentation via W3 and the RFCs but I have yet to find documentation that explains how a click event on...
3
by: gary | last post by:
Hi, I am trying to reference an anchor in a user control with a url. This worked in 1.1 but no longer works in 2.0. The ascx control is located in a "/include" folder If you have a...
6
by: Nalaka | last post by:
Hi, Is there a gui control in VS2005 to set a "named anchor"? For an example now I go to the html and write the following code <a name="jumpToThisLocation"/>
3
by: axlq | last post by:
I wrote the function below to get the vertical scroll position of an anchor. That is, a URL of the form http://www.example.com/mypage.html#anchorname should scroll to the point on the page that...
6
by: jim039845 | last post by:
The link looks like this: http://www.postpositive.net/library.php#cat6 The target looks like this: <a name="cat6">cat6</a> The link resides on this page:
8
by: azjudd | last post by:
Thank you in advance for your help on this one. I'm using named anchor tags on a FAQ page with questions listed at the top and answers below; a standard jump-to feature. However, anytime an anchor...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.