Results 1 to 10 of 10

Thread: href="#thumb"

  1. #1
    Join Date
    May 2011
    Posts
    48
    Thanks
    17
    Thanked 1 Time in 1 Post

    Default href="#thumb"

    I have this line of code which was provided by others.

    <a class="thumbnail" href="#thumb"><img alt="" src="images/Thumb_ESGChtA.jpg" width="100px" height="66px" border="0" />

    The word thumb is not defined anywhere else in the document by name. Does this mean it points to itself?

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    That is an anchor link it looks for the corresponding anchor name which should be else where on that page.

    Code:
    <a name="thumb"></a>
    Corrections to my coding/thoughts welcome.

  3. The Following User Says Thank You to bluewalrus For This Useful Post:

    Atom (05-12-2011)

  4. #3
    Join Date
    May 2011
    Posts
    48
    Thanks
    17
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by bluewalrus View Post
    That is an anchor link it looks for the corresponding anchor name which should be else where on that page.

    Code:
    <a name="thumb"></a>
    The word thumb does not appear anywhere else on the page, nor does the word name.

  5. #4
    Join Date
    May 2011
    Posts
    48
    Thanks
    17
    Thanked 1 Time in 1 Post

    Default

    Here is the entire page.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Gallery</title>
    <style type="text/css">
    
    /*Credits: Dynamic Drive CSS Library */
    /*URL: http://www.dynamicdrive.com/style/ */
    
    .gallerycontainer{
    position: relative;
    /*Add a height attribute and set to largest image's height to prevent overlaying*/
    }
    
    .thumbnail img{
    border: 1px solid white;
    margin: 0 5px 5px 0;
    }
    
    .thumbnail:hover{
    background-color: transparent;
    }
    
    .thumbnail:hover img{
    border: 1px solid blue;
    }
    
    .thumbnail span{ /*CSS for enlarged image*/
    position: absolute;
    background-color: lightyellow;
    padding: 5px;
    left: -1000px;
    border: 1px dashed gray;
    visibility: hidden;
    color: black;
    text-decoration: none;
    }
    
    .thumbnail span img{ /*CSS for enlarged image*/
    border-width: 0;
    padding: 2px;
    }
    
    .thumbnail:hover span{ /*CSS for enlarged image*/
    visibility: visible;
    top: 0;
    left: 230px; /*position where enlarged image should offset horizontally */
    z-index: 50;
    }</style>
    </head>
    <body>
    <div class="gallerycontainer">Mouse over thumbnail for full sized image. (UNDER CONSTRUCTION)</div>
    <div class="gallerycontainer">&nbsp;</div>
    <div class="gallerycontainer">
    <a class="thumbnail" href="#thumb"><img alt="" src="images/Thumb_ESGChtA.jpg" width="100px" height="66px" border="0" />
    <span><img alt="" src="images/ESGChtA.jpg" /><br />
    ESCombo</span></a>
    <a class="thumbnail" href="#thumb"><img alt="" src="images/Thumb_ESGChtA.jpg" width="100px" height="66px" border="0" />
    <span><img alt="" src="images/ESGChtB.jpg" /><br />
    Alligator</span></a><br />
    </div>
    </body>
    </html>

  6. #5
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Oh, yes than the '#thumb' does nothing other than I think keep the page standard compliant.
    Corrections to my coding/thoughts welcome.

  7. The Following User Says Thank You to bluewalrus For This Useful Post:

    Atom (05-12-2011)

  8. #6
    Join Date
    May 2011
    Posts
    48
    Thanks
    17
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by bluewalrus View Post
    Oh, yes than the '#thumb' does nothing other than I think keep the page standard compliant.
    So it really doesn't do anything?

    I checked, and the page acts the same whether you use "thumb" or "xyz." I've had a very hard time finding any documentation of this.
    Last edited by Atom; 05-12-2011 at 08:16 PM.

  9. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    That's:

    http://www.dynamicdrive.com/style/cs...image-gallery/

    And what you've been saying is mostly correct. However, it has nothing to do with compliance. The a tag needs an href in order for the css to work in IE 6. Using a hash (#) for that suffices and generally does nothing else. However, in some cases (quite rare, only in older browsers or in all browsers if the page is hosted on certain hosts) it will reload the page if clicked. But in all browsers, it can - depending upon the layout and the scroll state of the page when and if the user clicks it, reposition the page. Because of this last I would recommend changing them from:

    Code:
    <a class="thumbnail" href="#thumb">
    to:

    Code:
    <a class="thumbnail" href="javascript:void(0);" onclick="return false;">
    That way it will still qualify as an anchor link for css purposes under IE 6, and will do absolutely nothing when clicked regardless of whether or not the user has javascript enabled, and/or has an older browser, and/or the page is hosted on certain hosts.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  10. The Following User Says Thank You to jscheuer1 For This Useful Post:

    Atom (05-13-2011)

  11. #8
    Join Date
    May 2011
    Location
    SFBA, CA, USA
    Posts
    94
    Thanks
    6
    Thanked 7 Times in 7 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    ...
    and if the user clicks it, reposition the page.
    ...
    @jscheuer1,

    Hi John. Your comment brings up an issue I've been trying to figure out. I have a very simple, straight-forward JS function that swaps divs on li click based upon <a href=#id. It, of course, repositions the page and I don't need it to. I just need the divs to swap.

    Here's the basics of the code. Do you see a way I could alter this just enough without having to replace it with new code altogether?

    Code:
    <ul class="triggers_PrjLst">
        <li class="triggerButton"><a href="#printProj" onclick="showPane('printProj')">PRINT</a></li>  <!--1st trigger-->
        <li class="triggerButton"><a href="#webProj" onclick="showPane('webProj')">WEB</a></li>  <!--2nd trigger-->
        <li class="triggerButton"><a href="#pptProj" onclick="showPane('pptProj')">SLIDE</a></li>  <!--3rd trigger-->
        <li class="triggerButton"><a href="#illProj" onclick="showPane('illProj')">CGI</a></li>  <!--4th trigger-->  
    </ul>
    
    
    
    <div id="thumbsContainer">
        <div id="printProj" class="projThumbs"></div>  <!--projThumbs 1st action-->    
        <div id="webProj" class="projThumbs"></div>  <!--projThumbs  2nd action-->
        <div id="pptProj" class="projThumbs"></div>  <!--projThumbs  3rd action-->
        <div id="illProj" class="projThumbs"></div>  <!--projThumbs  4th action-->
    </div>
    
    
    <SCRIPT LANGUAGE="javascript">
      function showPane(id) {
      var e,i;
      var PID = "thumbsContainer"; // the id of the parent element
      var p = document.getElementById(PID); // parent element
      // loop through each of the childNodes of the parent element
      for (i=0; i<p.childNodes.length; i++) {
        e = p.childNodes[i];
        if (e.nodeType!=1) continue; // pass over non-element nodes
        if (e.getAttribute("id") == id) {
          e.style.display = "block";
        }
        else {
          e.style.display = "none";
        }
      }
    }
    </SCRIPT>


    Thanks in advance,
    dbc

  12. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    If your goal is to display the hash (#printProj, etc.) in the address bar, no. There's no way.

    However, if you would be happy without that (the hash will still show in the status bar on hover of the link if the browser has that feature enabled), just have each onclick return false, example:

    Code:
    <a href="#printProj" onclick="showPane('printProj'); return false;">PRINT</a>
    But, it looks like you're changing the display property of divisions. If so, this in and of itself can cause the page to jump around. To prevent that, thumbsContainer should have its dimensions set to a height equal to or greater than the maximum height of its content when everything that can be revealed within it is revealed, and if it's a factor, similarly with its width. You may already have dealt with that, you don't show the page's style. And all that part should only be a factor if there's content beside thumbsContainer and/or below it. Or possibly if it's the last thing on a page that's either taller or wider than the window.

    It's possible I'm missing something, either misunderstanding the question, or not correctly visualizing what the code does/would do.

    If you want more help:

    Please post a link to a page on your site that contains the problematic code so we can check it out.


    And tell me what I need to do to see the problem.
    Last edited by jscheuer1; 05-14-2011 at 02:17 AM. Reason: Add: Or possibly if it's . . .
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  13. The Following User Says Thank You to jscheuer1 For This Useful Post:

    deathbycheese (05-14-2011)

  14. #10
    Join Date
    May 2011
    Location
    SFBA, CA, USA
    Posts
    94
    Thanks
    6
    Thanked 7 Times in 7 Posts

    Default

    Hooray! 'return false' did the trick. You're a freakin' god, dude!

    dbc

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
  •