Now that I have the solution, it was pretty simple. Here is an example of how to blick an image using Javascript. The image will either be hidden or displayed becase upon the value passed to the function.

I'm posting this for reference because I couldn't find any examples of how to blink an image and then leave it either hidden or visible after blinking.

<!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">
<head>
    <title>Blinking Image</title>

<script type="text/javascript">
function toggle_visibility(hideorshow)
{
    var e = document.getElementById("alerticon");
    if (hideorshow == 'hide')
    {
        if (e.style.visibility == 'visible')
        {
            blink(6);
        }
        else
        {
            blink(7);
        }
    }
    else
    {
        if (e.style.visibility == 'visible')
        {
            blink(7);
        }
        else
        {
            blink(6);
        }
    }
}
function blink(count)
{
    var count = count
    var e = document.getElementById("alerticon");
    e.style.visibility = ( e.style.visibility == 'visible' )? 'hidden' : 'visible';
    count--;
    if (count <= 0)
    {
    return;
    }
    else
    {
        setTimeout("blink('" + count + "');", 500);
    }
}
</script>

</head>
<body>
    <p>
        <img id="alerticon" alt="alert" src="exclamation_red_16x16.gif" style="visibility:hidden" />
    </p>
    <a href="#" onclick="toggle_visibility('hide')">SHOW</a><br /><a href="#" onclick="toggle_visibility('show')">HIDE</a>
</body>
</html>

 

posted on Friday, June 20, 2008 2:14 PM
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Comments

Gravatar
# re: JavaScript: Hide Or Show Image With Blink
posted by rakesh
on 5/5/2009 3:52 AM
yah , its good job !

actually i used this on my gps tracking site

thanx

Gravatar
# re: JavaScript: Hide Or Show Image With Blink
posted by ماسنجر
on 5/17/2010 11:12 AM
Thanks for this useful information
Gravatar
# re: JavaScript: Hide Or Show Image With Blink
posted by Yogesh Ugale
on 9/27/2010 1:57 AM
Very Nice solution i found on your site after serching 3 and half hours on net.
thanks, very much.
Gravatar
# re: JavaScript: Hide Or Show Image With Blink
on 3/1/2011 9:23 AM
Thanks a lot I was Searching since one week
So nice of you
Gravatar
# re: JavaScript: Hide Or Show Image With Blink
posted by M. A. Torsekar
on 5/3/2011 7:26 AM
function blink(count)
{
var count = count
var e = document.getElementById("alerticon");
e.style.visibility = ( e.style.visibility == 'visible' )? 'hidden' : 'visible';
count--;
if (count <= 0)
{
return;
}
else
{
setTimeout("blink('" + count + "');", 500);
}
}
can anyone tell me how this functin works? I am not getting it.

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: