Flash graphic on mouseover -

They have: 5,633 posts

Joined: Jan 1970

I would like to have a gif flash and then go back to the original gif when you put your mouse over the image. Can you string two events together on a mouseover event?
Thanks for your help

John Pollock's picture

He has: 628 posts

Joined: Mar 1999

I got this script to do the trick:

<HTML>
<HEAD>
<TITLE>flashit</TITLE>

<SCRIPT language="JavaScript">
<!--

if (document.images)
{
pic1on= new Image(100,25);
pic1on.src="image2.gif";

pic1off= new Image(100,25);
pic1off.src="image1.gif";
}

var getit=" ";

function flashit(imgName)
{
if (document.images)
{
getit=imgName;
imgOn=eval(imgName + "on.src");
document[imgName].src= imgOn;
setTimeout('flashout()',500);
}
}

function flashout()
{
iname=getit;
imgOff=eval(iname + "off.src");
document[iname].src= imgOff;
}

//-->
</SCRIPT>

</HEAD>
<BODY>
<A HREF="http://someplace.com" onMouseover="flashit('pic1')">
<IMG SRC="image1.gif" name="pic1" width="100" height="25">
</A>
</BODY>
</HTML>

You'll need to change the script to go with your image urls and the link url.

You can change the amount of time the flash lasts by adjusting the number 500 in the setTimeout function higher or lower.

I have a working example up if you want to see it at:

http://www.pageresource.com/zzztest/flashtest.htm

------------------
John Pollock
www.pageresource.com
www.javascriptcity.com

[This message has been edited by John Pollock (edited April 22, 1999).]

[This message has been edited by John Pollock (edited April 22, 1999).]

[This message has been edited by John Pollock (edited April 22, 1999).]

They have: 3 posts

Joined: Nov 2009

that worked well for me also. is there a reference as to how to make it make a sound at the same time as the mouseover? the noise of a camera click, for example, when you mouseover a camera? any thoughts always appreciated.
Rick

They have: 5,633 posts

Joined: Jan 1970

Hey John,

Thanks, thanks and dare I say thanks. This is the second time you have helped me and I greatly appreciate it.

They have: 2,390 posts

Joined: Nov 1998

Jim,
Just call him beautiful - it always does the trick (private-ish joke, if anyone is wondering...)
JP

John Pollock's picture

He has: 628 posts

Joined: Mar 1999

Jim,

You're welcome. Like JP says, just cal me beautiful- it usually works. *laugh*

------------------
John Pollock
http://www.pageresource.com
http://www.javascriptcity.com

They have: 5,633 posts

Joined: Jan 1970

Hey John,(Beautiful)

My page is working just like I wanted it to. I would like you to look at it and confirm my suspicion about the page loads. If you would go to www.discoverynet.com/~tekguy/ and look at the first page. (We are doing a proposal for a pet food company, my first foray into doing a site for profit) The only pages that work are the home and product pages. When you click on products it takes forever to start to switch pages. I think it is because the graphics on the rollovers are being preloaded. If you get a chance would you check it out?

Thanks again

John Pollock's picture

He has: 628 posts

Joined: Mar 1999

I didn't have a problem with the page transition, and in Netscape things seemed to work just fine for me.

In IE, I got an Active X error (I think this is something on my computer though, it has been bugging me for months. It tells me I have my security settings set too high, and they are not!).

The audio enhancements might be bothersome to those without the plugin (Beatnik?). IE seemed to try to download the file, which caused the page to hang- then the Active X problem hit me and I couldn't do anything.

In Netscape I had no trouble, and I got a nice message about needing the plugin.

In any case, the transition didn't take long for me. If you have that trouble, it may be the audio file- I didn't have the plugin so I didn't have to try loading it.

Hopefully someone without the activeX problem I have can check it out in IE for you.

------------------
John Pollock
http://www.pageresource.com
http://www.javascriptcity.com

They have: 2,390 posts

Joined: Nov 1998

I tried in IE5 and had no problems what so ever - the pop up came up fine and the products page seemed fine as well.
Nice site.
JP

------------------
The Webmaster Promotion and Resource Site
www.what-next.com
The NEXT step in Designing and Promoting your Website

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.