funeralcrasher: (Default)
funeralcrasher ([personal profile] funeralcrasher) wrote2005-12-01 08:22 pm
Entry tags:

unusual request - blinking img

Could I make an image 'blink' off an on, using Javascript?  (in case you wondered an animated gif is not an option in this project)    How would I do this?

[identity profile] eringurrl.livejournal.com 2005-12-02 02:31 am (UTC)(link)
if you give the img tag an id it makes it easier to reference in javascript then you can just change the image's source attribute to like an image that is all white, put that into a loop...

function getObj(objId)
{	
    if (document.layers) 
        return document.layers[objId]; 
    if (document.getElementById) 
        return document.getElementById(objId); 
    if (document.all) 
        return document.all[objId]; 
    if (document[objId]) 
        return document[objId]; 
    return false;
}

var orgSource = "";
While True {
    orgSource = getObj("imageidname").src
    getObj("imageidname").src = "http://...";
    //some sorta wait timer
    getObj("imageidname").src = orgSource;
}


I'd imagine something to that effect.

[identity profile] pkbarbiedoll.livejournal.com 2005-12-02 08:22 am (UTC)(link)
okay, or I could use an invisible spacer pixel, resized to the image I'm replacing.. I'll try this tomorrow & will let you know how it goes. :)

[identity profile] eringurrl.livejournal.com 2005-12-02 04:38 pm (UTC)(link)
You could use really whatever would suit your needs best :P
I think .width = x and .height = y works to resize the image in code.