Results 1 to 10 of 10

Thread: Thumbnail viewer 'active thumb' question.

  1. #1
    Join Date
    May 2007
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Thumbnail viewer 'active thumb' question.

    2) http://www.dynamicdrive.com/dynamici...thumbnail2.htm

    3) Hi, 'Im using thumbnail2' and would dearly like the 'active thumb' to look active even when the mouse is removed until another thumb is moused over.(by way of a border highlight or something). Is this possible or am I dreaming? Many thanks.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    The image that was moused over last is still being displayed, so it's easy enough to tell which it was.
    You want a border around the active image?

    Seems like you could use a function to do that.

    You could have onMouseover= turn off all borders and then turn on the border for that particular image.

    The actual code might be a bit complex, though. Not quite sure where to start.

    onMouseover="this.border.width=3;" seems logical enough (if this is the right property, but I'd have to look that up), but setting all of the others to off would be difficult. I'll think and see if I come up with anything.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    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

    Put something like this in the head of the page:

    Code:
    <style type="text/css">
    .thumb {
    border:4px solid white;
    }
    </style>
    The width of the border is up to you, the color should be the same as the background color behind the thumbnails or a color of your choosing that indicates that a thumbnail is inactive.

    Give each thumbnail a class name of thumb:

    Code:
    <a href="photo1.jpg" rel="enlargeimage::mouseover" rev="loadarea"><img class="thumb" src="photo1_tbn" width="50" height="50"></a>
    Put this script at the end of the page, just before the closing </body> tag:

    Code:
    <script type="text/javascript">
    (function(){
    var i=0, t=document.images, hlight=function(e){
    var e=e? e : window.event;
    var el=e.target? e.target : e.srcElement;
    for (i = 0; i < t.length; i++)
    if(t[i].className=='thumb')
    t[i].style.borderColor='';
    el.style.borderColor='navy'; //Edit hightlight color as desired.
    }
    for (i = 0; i < t.length; i++)
    if(t[i].className=='thumb')
    if ( typeof window.addEventListener != "undefined" )
        t[i].addEventListener( "mouseover", hlight, false );
    else if ( typeof window.attachEvent != "undefined" )
        t[i].attachEvent( "onmouseover", hlight );
    else {
        if ( t[i].onmouseover != null ) {
            var oldOnmouseover = t[i].onmouseover;
            t[i].onmouseover = function ( e ) {
                oldOnmouseover( e );
                hlight(e);
            };
        }
        else
            t[i].onmouseover = hlight;
    }
    })();
    </script>
    Last edited by jscheuer1; 05-29-2007 at 07:32 AM. Reason: close style block
    - John
    ________________________

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

  4. #4
    Join Date
    May 2007
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi John,

    Thanks once again for your help. I cant seem to make this code work. Maybe its just something silly? The page is not live at the moment but here is the 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" lang="en" xml:lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title></title>

    <link rel="stylesheet" type="text/css" href="main.css" />

    .thumb {
    border:4px solid white;
    }


    <script type="text/javascript" src="thumbnailviewer2.js" defer="defer">

    /***********************************************
    * Image Thumbnail Viewer II script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
    * This notice must stay intact for legal use
    ***********************************************/

    </script>

    </head>
    <body>
    <div id="maincontainer">

    <div id="topsection"><div class="innertube"> <img border="0" src="images/name.gif" alt=""/></div></div>

    <div id="contentwrapper">
    <div id="loadarea">
    <div class="innertube"> <b> <em></em></b></div>
    </div>
    </div>
    <div id="leftcolumn">
    <ul>
    <li id="active"><a href="page1.html">1</a></li>
    <li><a href="page2.html">2</a></li>
    <li><a href="page3.html">3</a></li>
    <li><a href="page4.html">4</a></li>
    <li><a href="page5.html">5</a></li>
    <li><a href="page6.html">6</a></li>
    </ul>

    <div class="innertube"><b> <em></em></b></div>
    </div>

    <div id="footer">
    <a href="images/V1.jpg" rel="enlargeimage::mouseover" rev="loadarea"> <img class="thumb" src="thumbnails/a.jpg" alt="" border="0" width="25" height="25" style="margin: 8px"/></a>


    <a href="images/1.jpg" rel="enlargeimage::mouseover" rev="loadarea"> <img class="thumb" src="thumbnails/a.jpg" alt="" border="0" width="25" height="25" style="margin: 8px"/></a>

    <a href="images/2.jpg" rel="enlargeimage::mouseover" rev="loadarea"> <img class="thumb" src="thumbnails/a.jpg" alt="" border="0" width="25" height="25" style="margin: 8px"/></a>



    <a href="images/5.jpg" rel="enlargeimage::mouseover" rev="loadarea"> <img class="thumb" src="thumbnails/a.jpg" alt="" border="0" width="25" height="25" style="margin: 8px"/></a>

    <a href="images/8.jpg" rel="enlargeimage::mouseover" rev="loadarea"> <img class="thumb" src="thumbnails/a.jpg" alt="" border="0" width="25" height="25" style="margin: 8px"/></a>


    <a href="images/7.jpg" rel="enlargeimage::mouseover" rev="loadarea"> <img class="thumb" src="thumbnails/a.jpg" alt="" border="0" width="25" height="25" style="margin: 8px"/></a>


    <a href="images/9.jpg" rel="enlargeimage::mouseover" rev="loadarea"> <img class="thumb" src="thumbnails/a.jpg" alt="" border="0" width="25" height="25" style="margin: 8px"/></a>


    <a href="images/V4.jpg" rel="enlargeimage::mouseover" rev="loadarea"> <img class="thumb" src="thumbnails/a.jpg" alt="" border="0" width="25" height="25" style="margin:8px"/></a>
    <br>
    </div>

    </div>
    <script type="text/javascript">
    (function(){
    var i=0, t=document.images, hlight=function(e){
    var e=e? e : window.event;
    var el=e.target? e.target : e.srcElement;
    for (i = 0; i < t.length; i++)
    if(t[i].className=='thumb')
    t[i].style.borderColor='';
    el.style.borderColor='navy'; //Edit hightlight color as desired.
    }
    for (i = 0; i < t.length; i++)
    if(t[i].className=='thumb')
    if ( typeof window.addEventListener != "undefined" )
    t[i].addEventListener( "mouseover", hlight, false );
    else if ( typeof window.attachEvent != "undefined" )
    t[i].attachEvent( "onmouseover", hlight );
    else {
    if ( t[i].onmouseover != null ) {
    var oldOnmouseover = t[i].onmouseover;
    t[i].onmouseover = function ( e ) {
    oldOnmouseover( e );
    hlight(e);
    };
    }
    else
    t[i].onmouseover = hlight;
    }
    })();
    </script>
    </body>
    </html>

    Many Thanks,
    Craig

  5. #5
    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

    This:

    Code:
    .thumb {
    border:4px solid white;
    }
    Needs to be in your main.css stylesheet file or else have style tags around it if you are going to use it in the head there:

    Code:
    <style type="text/css">
    .thumb {
    border:4px solid white;
    }
    </style>
    Partly my fault, as I pasted it into my previous post without its closing </style> tag. I've fixed it there as well.
    - John
    ________________________

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

  6. #6
    Join Date
    May 2007
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks John - that's starting to work. (I should have noticed the </style>).

    Just one prob...
    The thumbs are highlighting just right but are now not cancelling when another thumb is moused over. Is there a simple solution to this?

    Many Thanks,
    Craig

  7. #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

    Worked fine here. I think I would need a link to your page to see what the problem is.
    - John
    ________________________

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

  8. #8
    Join Date
    May 2007
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hmmm.
    Just tried it in Firefox, Opera and NN. It works a treat there. Thankyou.
    The not cancelling seems to be a Safari issue. Any ideas?
    Thanks,
    Craig

  9. #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

    Well, I don't know too much about Safari, but I'd try changing this:

    Code:
    (function(){
    var i=0, t=document.images, hlight=function(e){
    var e=e? e : window.event;
    var el=e.target? e.target : e.srcElement;
    for (i = 0; i < t.length; i++)
    if(t[i].className=='thumb')
    t[i].style.borderColor='';
    el.style.borderColor='navy'; //Edit hightlight color as desired.
    }
    for (i = 0; i < t.length; i++)
    if(t[i].className=='thumb')
    if ( typeof window.addE . . .
    to:

    Code:
    t[i].style.borderColor='white';
    Or to whatever color you are using for 'inactive'.
    - John
    ________________________

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

  10. #10
    Join Date
    May 2007
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Genius.
    I think you may know a little more about Safari than you think!
    That works perfectly.

    Thank you so much.

    Craig

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
  •