Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    •  
      CommentAuthorkenbacca
    • CommentTimeJul 19th 2006
     permalink
    I'm stuck on something.

    I'm creating a new Image as a placeholder to get the width / height before I set the dimensions of a Node that I'm switching out.

    The first time you click on the link, the dimensions are not set, but if you click on it a second time it works.

    I was using alerts to test this, and if I do 2 alerts in a row the second one will have the dimensions.

    Am I missing something here?

    Here is a link to the page in question....
    http://sharonsiskin.org/temp/community.htm

    Here is the culprit......
    function replaceImageNode(id, element){
    var img = document.getElementById(id);

    temp_img = new Image;
    temp_img.src = element;

    var i = img.cloneNode(true);
    i.src=element;
    i.width = temp_img.width;
    i.height = temp_img.height;

    var parent = img.parentNode;
    parent.replaceChild(i, img);
    return i;
    }
    •  
      CommentAuthorfake
    • CommentTimeJul 20th 2006
     permalink
    It does seem to work on the test page you provided...

    Usually, the whole image needs to be fully loaded when you start plaing with its propreties. Its a possibility that the image was not fully loaded when you start cloning the node. I can't be sure though. Try to add a function to the onload event on your image (not sure if it exists) that will alert a message. See if it pops before or after the width and height assignments.
    •  
      CommentAuthorkenbacca
    • CommentTimeJul 20th 2006
     permalink
    Thanks for the suggestion. I'll try this out and let you know how it works....
    •  
      CommentAuthorpremii
    • CommentTimeJul 21st 2006
     permalink
    as fake suggested, use image onload event. , I have created something similar, premii-using-nikon-d70/84" target="_blank" rel="nofollow">http://foto.premii.compremii-using-nikon-d70/84 (try on FF).

    After the page is loaded, I am downloading next and previous image, Once next & prev images are loaded, onLoad events get fire.

    If you mouse over foto, you will see next and previous arrow buttons after onload events are fired.
Add your comments
    Username Password
  • Format comments as (Help)