SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Evangelist
    Join Date
    Jul 2008
    Location
    Port Elizabeth, South Africa
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    browsers don't see target in site map

    Hi - I generated my site map at www.xml-sitemaps.com. Saved the sitemap.html, went into it and added the target

    <a name="shop"></a>

    above the shop area

    The browsers don't see it, so that:

    http://www.greensmoothie.com/sitemap.html#shop

    will take you to the top of sitemap and not to the top of shop/ within sitemap.

    When I view source, I can see the target is there. Does anyone perhaps know why browsers don't see it?

    thanks for your kind help - Val

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,175
    Mentioned
    454 Post(s)
    Tagged
    8 Thread(s)
    As a link, http://mypage.html#shop (for example) will go to mypage.html and then look for an element on that page with an ID of #shop. If it doesn't find one, it will just go to the top of the page. So you have to add such an ID to the relevant element. E.g.

    Code:
    <div id="shop" class="lhead">shop/<span class="lcount">13 pages</span></div>

  3. #3
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,888
    Mentioned
    122 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by valarcher View Post
    Hi - I generated my site map at www.xml-sitemaps.com. Saved the sitemap.html, went into it and added the target

    <a name="shop"></a>

    above the shop area

    The browsers don't see it, so that:

    http://www.greensmoothie.com/sitemap.html#shop

    will take you to the top of sitemap and not to the top of shop/ within sitemap.

    When I view source, I can see the target is there. Does anyone perhaps know why browsers don't see it?
    You need to put the tag inside a table cell.
    (Actually, what you need to do is to ditch the table layout and join the 21st century, but we'll leave that to one side for the moment)

    If you had typed some random text at the point where you put <a name="shop"></a>, it would have appeared above the table, because that's what happens to text between the start <table> and end </table> but isn't in a content-containing element, ie a <td> or <th>. It's exactly the same with the anchor - because it isn't legally placed inside a table cell, it bobs up to sit on top of the table.

    Of course, it's much better to put id="shop" on the element you want to jump to rather than messing around with named anchors anyway, and that would solve the problem even more easily.

    A couple of other tips:
    1. You don't need any of those class="lpage"s, you can achieve the effect better with child selectors.
    2. Take out http://www.greensmoothie.com from every link, it's completely unnecessary.
    3. Only use a title attribute on a link when it adds something extra. If all you're doing is repeating the text that is visible (or at most adding some filler like "Click here to...") then there's no point in having the title there, it just adds complications.

  4. #4
    SitePoint Evangelist
    Join Date
    Jul 2008
    Location
    Port Elizabeth, South Africa
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HI guys - thank you! - both methods work perfectly so followed your advice + just added "id="shop" in front of shop/. I learned something new - on rest of site where I've updated it to legal markup (deleted all the table's) I still use the old <a name="shop"></a> method. So now I'll have to go into a gazillion pages and change the targets to id=

    Remember "I generate my site map at www.xml-sitemaps.com." I don't touch the file they generate (it'd be huge waste of my time since I generate it so often) except for that one "shop" target I must add (I link to it from rest of site).

    thanks! - Val


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •