Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: browser/anchor problem  (Read 4247 times)

0 Members and 1 Guest are viewing this topic.

amalafrida

    Topic Starter


    Greenhorn

    • Yes
    • yellowloam
  • Experience: Experienced
  • OS: Linux variant
browser/anchor problem
« on: November 01, 2010, 03:44:43 PM »
Code: [Select]
<a href = "somepage.html#p1">link</a>
Problem: when I click the link and go to the page and the browser drops me down into the text of somepage.html at the named anchor, the code marked:
Code: [Select]
<a name="p1"></a> ... the text line in somepage.html is all the way up at the top of the browser window.  So far up in fact that I can see only half of the line height.

How to correct this?  How do I get the browser to provide a few lines, or even just one line, above the link mark

Thanks in advance.

kpac

  • Web moderator
  • Moderator


  • Hacker

  • kpac®
  • Thanked: 184
    • Yes
    • Yes
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 7
Re: browser/anchor problem
« Reply #1 on: November 01, 2010, 03:54:17 PM »
Quote
the text line in somepage.html is all the way up at the top of the browser window.
What do you mean by this?

So when you click the link, you are brought to the right place on the page?

amalafrida

    Topic Starter


    Greenhorn

    • Yes
    • yellowloam
  • Experience: Experienced
  • OS: Linux variant
Re: browser/anchor problem
« Reply #2 on: November 01, 2010, 04:19:28 PM »
I have a line of text and code that looks something like this:
Code: [Select]
text ... text ... text <a name="this"></a>
when I click on a link that will take me to this page and named location, everything works fine.  I am taken to the page and the named location ... however, the line of text is all the way up at the top of the viewport ... so far up that only half of the line height is visible.  If I hit the up arrow key, the text scrolls fully into view.

Imagine the line of text linked to ... "text ... text ... text" I should see that line of text; it should be a line of text at the top of the viewport, however, I only see half of a line ... half of the e's vertical height, half of the "t" etc ...

Make sense ???

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: browser/anchor problem
« Reply #3 on: November 01, 2010, 05:28:38 PM »
Imagine the line of text linked to ... "text ... text ... text" I should see that line of text; it should be a line of text at the top of the viewport, however, I only see half of a line ... half of the e's vertical height, half of the "t" etc ...
[/quote]
Make sense ???
[/quote]

in your example, "text ... text ... text" is NOT the anchor text. the anchor text appears between the  <a> and <  /a> tags, in this case, nothing.

Try:

Code: [Select]
<a name="this">text ... text ... text </a>

Wether that will fix it, I don't know.
I was trying to dereference Null Pointers before it was cool.

amalafrida

    Topic Starter


    Greenhorn

    • Yes
    • yellowloam
  • Experience: Experienced
  • OS: Linux variant
Re: browser/anchor problem
« Reply #4 on: November 02, 2010, 10:46:29 AM »
Ok.  Take a look at this page:
http://www.yellowloam.com/gibbon/frames/maximspage.html

click on the first box labeled " ...see it in context" ... this will take you to a page that shows the quote as it occurs in the full chapter ... note that the first line is slightly hidden by the top frame of the browser ... I've discovered that this occurs with Firefox. 

Chrome and Opera get it right ... don't have IE ... is this a known Firefox bug

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: browser/anchor problem
« Reply #5 on: November 02, 2010, 10:59:18 AM »
As I said before, you aren't using <a name="xxxx"> correctly. there needs to be text between the beginning and ending tags or else you will encounter issues when the now empty <a> element wraps incorrectly. The fact that you are using the tag wrong combined with the kooky stylesheet are probably causing your issue. (I tested this myself, I was unable to get any Anchors to work incorrectly in the fashion portrayed by the link provided)
I was trying to dereference Null Pointers before it was cool.

amalafrida

    Topic Starter


    Greenhorn

    • Yes
    • yellowloam
  • Experience: Experienced
  • OS: Linux variant
Re: browser/anchor problem
« Reply #6 on: November 02, 2010, 11:39:09 AM »
Good.  Thanks.  Care to be more specific about the "kooky" stylesheet?  What exactly does "kooky" mean?  One or two pieces of specific advice would be appreciated.

Cordially ...

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: browser/anchor problem
« Reply #7 on: November 02, 2010, 12:37:29 PM »
Good.  Thanks.  Care to be more specific about the "kooky" stylesheet?  What exactly does "kooky" mean?  One or two pieces of specific advice would be appreciated.

it's using pixel-exact measurements. Not the end of the world, but it might be a combination of both that was causing the problem.

(although looking at it now, it seems to be working properly)
I was trying to dereference Null Pointers before it was cool.

amalafrida

    Topic Starter


    Greenhorn

    • Yes
    • yellowloam
  • Experience: Experienced
  • OS: Linux variant
Re: browser/anchor problem
« Reply #8 on: November 02, 2010, 05:37:42 PM »
Ok, very good, my friend.  thanks for all your help and the spot-on advice.  Sorry it took me two slaps up side the head to get it right, but I thought I'd set the anchor up correctly this morning and it did not work ... obviously I did something wrong.

In any case, I've gone back and tacked a zero-width space, &#x200b;, between the every one of the 32,327 open and close tags.  Now, all is cool.

I'm always astonished at my ignorance.  No matter how many errors I've come across, I always want to blame it on a "bug" in the software.  And just about 99% of the time it's me.

r.