Click to See Complete Forum and Search --> : frame image flipping


robino
11-22-2002, 07:53 AM
Hello!

I tried to flip some images in a HTML page. It worked fine but if I put it into a frame, images are all the time dowloaded from server.
Here's my source code:

<html>
<head>
<script language="JavaScript">
<!--
btn_unsel=new Image();
btn_unsel.src="btn_unsel.gif";
btn_sel=new Image();
btn_sel.src="btn_sel.gif";
//-->
</script>
</head>
<body>
<a href="whatever.html" target="main_frame"
onmouseover="btn.src='btn_sel.gif'"
onmouseout="btn.src='btn_unsel.gif'">
<img name="btn" border=0 src="btn_unsel.gif">
</a>
</body>
</html>

Any idea? Thanks.

Robino

Zach Elfers
11-22-2002, 12:00 PM
Your image has a name, btn. In the link where it says onmouseover, don't just put btn.src. Put document.btn.src. That should work.:)

Beach Bum
11-22-2002, 11:22 PM
document.btn.src='btn_sel.src'

you also have the wrong name for the source. you are using the gif again rather than the variable where you stored it.

gil davis
11-23-2002, 08:17 AM
Originally posted by Beach Bum
document.btn.src='btn_sel.src'

you also have the wrong name for the source. you are using the gif again rather than the variable where you stored it.

If that is true, then you don't want the VAR inside quotes. It should be:

document.btn.src = btn_sel.src;

Beach Bum
11-23-2002, 10:01 AM
oops - sorry - yes no quotes on the variable. i must have been half asleep.

robino
11-27-2002, 06:18 AM
Thank you all for your help but I still have the problem. I tried everything, I don't understand...:confused:

Xeenslayer
11-28-2002, 05:34 AM
Uh, I'm not too sure, but do you need a semicolon ( ; ) after your event handlers? I always put one in after an 'onMouseOver' and 'onMouseOut'.

Beach Bum
12-02-2002, 12:28 PM
no ; needed in our example. the ; is ued to separate more than one script statement.