Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question This script works in IE but not in Firefox

    I wonder why this script for zooming the icons/images works flawlessly in Internet Explorer, but fails to do anything in Firefox. any idea?


    here's the code for the script i'm using:

    Code:
    function setZoom(img, dir, width, height, margin, zIndex, delay) {
      setTimeout(function() {
        if (img.dir==dir) {
          img.style.width=width;
          img.style.height=height;
          img.style.margin=margin;
          img.style.zIndex=zIndex;
          img.parentNode.parentNode.style.zIndex=zIndex;
        }
      }, delay);
    }
    
    function larger(img, width, height) {
      img.dir='rtl';
      now=parseInt(img.style.zIndex);
      for (i=now+1; i<=10; i++) {
        w=(width*(10+i))/20+'px';
        h=(height*(10+i))/20+'px';
        m=(-i)+'px 0 0 '+(-width*i/40)+'px';
        setZoom(img, 'rtl', w, h, m, i, 20*(i-now));
      }
    }
    
    function smaller(img, width, height) {
      img.dir='ltr';
      now=parseInt(img.style.zIndex);
      for (i=now-1; i>=0; i--) {
        w=(width*(10+i))/20+'px';
        h=(height*(10+i))/20+'px';
        m=(-i)+'px 0 0 '+(-width*i/40)+'px';
        setZoom(img, 'ltr', w, h, m, i, 20*(now-i));
      }
    }
    here is its working link for internet explorer: http://www.almurtazaschool.com/zoomcheck.php

    it works as a beauty in IE, but i wonder what's the reason its not working in firefox. (i don't have sufficient knowledge about JScript).

    thanks

  • #2
    Regular Coder
    Join Date
    Jul 2007
    Location
    UK
    Posts
    223
    Thanks
    0
    Thanked 14 Times in 14 Posts
    You need to change this line in the "larger" and "smaller" functions:
    Code:
    now=parseInt(img.style.zIndex);
    with this:
    Code:
    if(!img.style.zIndex){
       now=0;
    }
    else{
      now=parseInt(img.style.zIndex);
    }
    Because when the element doesn't have a z-Index in Firefox parseInt(img.style.zIndex) equates to 'NaN' instead of 0 as it does in IE so the code in the for loop never gets run in Firefox.


  •  

    Posting Permissions

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