Announcement

Collapse
No announcement yet.

Linking to a certain section of another page...bug?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Linking to a certain section of another page...bug?

    I know how this is accomplished...

    <a href="http://blah.com/page2.html#section2"><a>

    on page2.html...

    <h2 id="section2"></h2>

    It works fine when I put the id on a header element, but if I try to put it on a div it doesn't work. Is this normal? I noticed it works in IE7, but not Firefox or Safari.

  • #2
    You should be targeting a named anchor, not an id:

    <a href="http://blah.com/page2.html#section2"><a>

    on page2.html...

    <a name="section2"><a><h2 id="section2"></h2>


    Digi
    The world is divided into people who think they are right.
    —Anonymous

    Comment


    • #3
      Originally posted by digizan View Post
      You should be targeting a named anchor, not an id:

      <a href="http://blah.com/page2.html#section2"><a>

      on page2.html...

      <a name="section2"><a><h2 id="section2"></h2>


      Digi

      seems a little weird to put a blank anchor tag doesn't it?

      Comment


      • #4
        Originally posted by MikeTheVike View Post
        seems a little weird to put a blank anchor tag doesn't it?
        Not to me it doesn't. ;-)

        You could wrap your anchor around the text of your heading:

        <h2 id="section2"><a name="section2">Foo<a></h2>

        But then you're probably going to have to add more CSS to stop the heading from looking like a link.

        Digi
        The world is divided into people who think they are right.
        —Anonymous

        Comment


        • #5
          Okay, I've been up all night finishing a web site and my brain is toast right now.

          This should work:

          <h2 id="section2" name="section2">Foo</h2>

          Digi
          The world is divided into people who think they are right.
          —Anonymous

          Comment


          • #6
            Originally posted by digizan View Post
            Okay, I've been up all night finishing a web site and my brain is toast right now.

            This should work:

            <h2 id="section2" name="section2">Foo</h2>

            Digi

            yea, it actually works with just the "id", the "name" isn't necessary. I was just wondering why it wasn't working on a div because it would make my heading a little more visible if the page jumped to the top of my div instead of the heading.

            Comment


            • #7
              Originally posted by MikeTheVike View Post
              yea, it actually works with just the "id", the "name" isn't necessary. I was just wondering why it wasn't working on a div because it would make my heading a little more visible if the page jumped to the top of my div instead of the heading.
              Yeah, now that I've gotten a couple of hours of sleep it's clear what you were asking. I should know better than to post on the forums when I'm dead tired like that.

              Anyway, I created a test page and have no problem jumping to a div using an id in either FF or Safari. Maybe you're overlooking something?

              Digi
              The world is divided into people who think they are right.
              —Anonymous

              Comment

              Search

              Collapse

              Advertisement

              Collapse

              Latest Topics

              Collapse

              • StudioMonkey
                Reply to Beauty in Graphic Design
                StudioMonkey
                Beauty in Graphic Design? Do not make the mistake of thinking that Graphic Design is art. It is not.

                We may achieve balance, harmony etc. in a layout but if the client hates it you still...
                Today, 09:28 AM
              • B
                Reply to Book Print Ads- Critique Wanted!!!
                B
                Probably not relevant to the assignment, but cloth-covered hardbacks are nearly always sold with paper dust jackets. It would be the dust jacket-covered book that would be shown in the ad since that's...
                Today, 09:16 AM
              • cornfed
                Reply to Keychain password problems
                cornfed
                I was able to restart this morning and change the keychain password. It looks like everything is synced up. I can log into the computer and get online. IT has me locked out of everything else. Hopefully...
                Today, 09:14 AM
              • Craig B
                Reply to Who is still alive from the oldies?
                Craig B
                I suppose I'm an oldie. Sigh.

                And i remember you and Ulysses. I don't post very often, but I do check in from time to time. Congrats on 10 years and the 3 kiddos.
                Today, 09:01 AM
              • kemingMatters
                Comment on How do you appraise a project for non-profit work?
                kemingMatters
                Different tax laws in the US I suppose. You are right that it is imperfect because you do still need to charge sales tax.

                there's nothing barring anyone from donating money to an NPO here,...
                Today, 08:45 AM

              GDF A division of Mediabistro Holdings Adweek | Mediabistro | Clio | Film Expo Group Contact Us | Terms of Use | Privacy Policy Copyright © 2016 Mediabistro Holdings
              Working...
              X