Results 1 to 3 of 3

Thread: Linked thumbs in Thumbnail Viewer II

  1. #1
    Join Date
    Sep 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Linked thumbs in Thumbnail Viewer II

    Script Title: Thumbnail Viewer II

    This script works perfectly as described. I have a small(?) modification request though.

    How to give the thubnails a clickable href, ie to another page, while keeping the swap image when onmouseover?

    That is:
    1. When mouse over a thumb, show "big" image in targetted div (rev='loadarea...), as usual.
    2. When thumbnail is KLICKED you will be taken to a defined destination (like when the big image is klicked).

    I appreciate your help.
    Cheers!

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    See if removing highlighted on thumbnailviewer2.js helps:
    Code:
    init:function(){ //Initialize thumbnail viewer script
    this.iefiltercapable=(this.iefiltercapable && this.enableTransition) //True or false: IE filters supported and is enabled by user
    var pagelinks=document.getElementsByTagName("a")
    for (var i=0; i<pagelinks.length; i++){ //BEGIN FOR LOOP
    if (pagelinks[i].getAttribute("rel") && /enlargeimage:/i.test(pagelinks[i].getAttribute("rel"))){ //Begin if statement: Test for rel="enlargeimage"
    var initType=pagelinks[i].getAttribute("rel").split("::")[1] //Get display type of enlarged image ("click" or "mouseover")
    if (initType=="mouseover"){ //If type is "mouseover", preload the enlarged image for quicker display
    this.preloadedimages[this.preloadedimages.length]=new Image()
    this.preloadedimages[this.preloadedimages.length-1].src=pagelinks[i].href
    pagelinks[i]["onclick"]=function(){ //Cancel default click action
    return false
    }
    }
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  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

    That's only half (if that much) of the battle. I believe there is a better way than messing with the main script.

    Quote Originally Posted by ursut View Post
    1. When mouse over a thumb, show "big" image in targetted div (rev='loadarea...), as usual.
    2. When thumbnail is KLICKED you will be taken to a defined destination (like when the big image is klicked).
    Well, yes - number 1 is no problem - it already does that if you configure it with:

    Code:
    rel="enlargeimage::mouseover"
    Now, of course if you were to use:

    Code:
    rel="enlargeimage::click"
    number 2 could never work out. So we must assume you are using the mouseover method. Now, where do you want it to go when the thumbnail is clicked? Like do you want it to go to the same place as the enlarged image, or to yet another page?

    In any case, we can add this code to the head of the page:

    Code:
    <script type="text/javascript">
    ;(function(){
    var extraClick = function(e){
    e = e || window.event;
    var t = e.target? e.target : e.srcElement? e.srcElement : null;
    if(t)
    t = t.rel && /enlargeimage::mouseover/.test(t.rel)? t : t.parentNode? t.parentNode : null;
    if(!t) return;
    if(t.rel && /enlargeimage::mouseover::.+/.test(t.rel))
    window.location.href = t.rel.split('::')[2];
    };
    if(window.addEventListener)
    document.addEventListener('click', extraClick, false);
    else if (window.attachEvent)
    document.attachEvent('onclick', extraClick);
    })();
    </script>
    Now we can add a link for any thumbnail, ex:

    Code:
    <a href="bulb.gif" rel="enlargeimage::mouseover::http://www.google.com/" rev="loadarea">Thumbnail</a>
    Last edited by jscheuer1; 09-30-2008 at 07:35 AM. Reason: improve modularity of code
    - John
    ________________________

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

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
  •