ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Anchors not working in Firefox and Safari

March 03, 2008 7:00pm

Subscribe [3]
  • #1 / Mar 03, 2008 7:00pm

    Eric Barstad

    198 posts

    I’m going nuts here…

    At the top of a page, I’ve got a subnav that links to anchor ids in the same page. But, for whatever reason, when I click on a link (e.g., #fiction”), it doesn’t take me all the way down to the anchor (i.e., <h3 id=“fiction”>Fiction Prize</h3>)—in some cases, it’s not even close. It works in IE6 and 7, but not in FF or Safari. Any ideas?

    Here’s my subnav:

    
    <a href="#fiction">Fiction</a> | <a href="#non-fiction">Non-Fiction</a> | <a href="#poetry">Poetry</a>
    

    And here’s a stripped down snippet of my template:

    {exp:weblog:entries weblog="submissions" status="winner|shortlisted" category="10" sort="asc" orderby="url_title" search:book_prize_year="{segment_2}"}
    {if count == "1"}<h3 id="fiction">Fiction Prize</h3>{/if}
    <div class="entry">
       {body}
    </div>
    {/exp:weblog:entries}
    
    {exp:weblog:entries weblog="submissions" status="winner|shortlisted" category="11" sort="asc" orderby="url_title" search:book_prize_year="{segment_2}"}
    {if count == "1"}<h3 id="non-fiction">Non-Fiction Prize</h3>{/if}
    <div class="entry">
       {body}
    </div>
    {/exp:weblog:entries}
  • #2 / Mar 03, 2008 7:52pm

    Ryan M.

    1511 posts

    I’ve always done those like this:

    {if count == "1"}
      <a name="fiction"> </a>
      <h3 id="fiction">Fiction Prize</h3>
    {/if}

    With the space being in there because they weren’t working with IE7 with nothing in the tag. Does that help? It’s an extra element, but sometimes you gotta do what you gotta do.

  • #3 / Mar 03, 2008 10:57pm

    Eric Barstad

    198 posts

    Thanks, Ryan. That does work. But I’m not sure why the ids didn’t—I’ve used them on non-EE sites before… maddening.

  • #4 / Mar 03, 2008 11:15pm

    Ryan M.

    1511 posts

    You know, I’ve had problems with using just the id’s whether it’s an EE site or not. I’ve just never had good luck with anchor links. Ah, well. Glad you got them working so you can tear your hair out over bigger things!

  • #5 / Mar 04, 2008 11:07am

    Andy Harris

    958 posts

    I did one of these only today, and the method you tried originally worked/works for me in Firefox and Safari, so it is a strange one. That’s the way I always do it, never have I seen it not work. Do you have an example I can see, you never know…

  • #6 / Mar 04, 2008 11:16am

    Ryan M.

    1511 posts

    I did one of these only today, and the method you tried originally worked/works for me in Firefox and Safari, so it is a strange one. That’s the way I always do it, never have I seen it not work. Do you have an example I can see, you never know…

    Andy, who are you speaking to? Which type of example are you looking for?

  • #7 / Mar 04, 2008 11:20am

    Eric Barstad

    198 posts

    Thanks, Andy. I’ve also gotten these to work in FF/Safari, so I’m not sure what the deal was here. Aside from unescaped ampersands there were no validation problems on the page either, so that wasn’t my problem. As Ryan mentioned, it’s a small thing to pull my hair out over, but small things are usually the worst.

  • #8 / Mar 04, 2008 11:22am

    Andy Harris

    958 posts

    Andy, who are you speaking to? Which type of example are you looking for?

    Sorry Ryan, I was talking to Eric! I always use the way he’s having problems with so I was offering to take a look just in case it was something silly (you know, the ones you just can’t spot no matter how hard you stare at it!).

  • #9 / Mar 04, 2008 11:36am

    Andy Harris

    958 posts

    Thanks, Andy. I’ve also gotten these to work in FF/Safari, so I’m not sure what the deal was here. Aside from unescaped ampersands there were no validation problems on the page either, so that wasn’t my problem. As Ryan mentioned, it’s a small thing to pull my hair out over, but small things are usually the worst.

    Oh I know exactly what you mean, this would bug the hell out of me which is why I was keen to find out what the problem was because I’ll be doing these in EE soon too.

  • #10 / Mar 06, 2008 11:31am

    minimal design

    356 posts

    Thanks, Andy. I’ve also gotten these to work in FF/Safari, so I’m not sure what the deal was here. Aside from unescaped ampersands there were no validation problems on the page either, so that wasn’t my problem. As Ryan mentioned, it’s a small thing to pull my hair out over, but small things are usually the worst.

    I know you got it working, but… since I hate when I don’t figure out exactly what is happening and you seem to be the same type 😉

    I’m guessing it might have to do with CSS collapsing margins  which don’t work the same in IE. You could try adding a 1px border to your old setup and see if you can see what’s going on with your block elements better.

    But it’s maybe a better idea to just move on though 😉

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases