Geeks With Blogs
The Trials and Tribulations of a Self-Taught Developer By Justin Russell

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 | Back to top


Comments on this post: JavaScript: Hide Or Show Image With Blink

# re: JavaScript: Hide Or Show Image With Blink
Requesting Gravatar...
yah , its good job !

actually i used this on my gps tracking site

thanx

Left by rakesh on May 05, 2009 3:52 AM

# re: JavaScript: Hide Or Show Image With Blink
Requesting Gravatar...
Thanks for this useful information
Left by ماسنجر on May 17, 2010 11:12 AM

# re: JavaScript: Hide Or Show Image With Blink
Requesting Gravatar...
Very Nice solution i found on your site after serching 3 and half hours on net.
thanks, very much.
Left by Yogesh Ugale on Sep 27, 2010 1:57 AM

# re: JavaScript: Hide Or Show Image With Blink
Requesting Gravatar...
Thanks a lot I was Searching since one week
So nice of you
Left by Abdul Hameed Satti on Mar 01, 2011 9:23 AM

# re: JavaScript: Hide Or Show Image With Blink
Requesting Gravatar...
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.
Left by M. A. Torsekar on May 03, 2011 7:26 AM

# re: JavaScript: Hide Or Show Image With Blink
Requesting Gravatar...
Is there a way to make this work without the hyperlink? when the page loads I want the image to blink and after blinking hide. Please help
Left by Dan on Mar 08, 2013 6:25 PM

Your comment:
 (will show your gravatar)


Copyright © Justin Russell | Powered by: GeeksWithBlogs.net