PDA

View Full Version : On mouseOver problem


Nirckoh
12-12-2002, 09:51 AM
Is there a much shorter way to do this function ...:thumbsup:

<SCRIPT LANGUAGE="JavaScript">

function on()
{
document.nick.src="friendbut1.bmp"
}
function off()
{
document.nick.src="friendbut.bmp"
}
function on1()
{
document.gal.src="galbut1.bmp"
}
function off1()
{
document.gal.src="galbut.bmp"
}
function on2()
{
document.lin.src="linkbut1.bmp"
}
function off2()
{
document.lin.src="linkbut.bmp"
}
function on3()
{
document.gam.src="gambut1.bmp"
}
function off3()
{
document.gam.src="gambut.bmp"
}
function on4()
{
document.dow.src="downbut1.bmp"
}
function off4()
{
document.dow.src="downbut.bmp"
}
</SCRIPT>
</head>
<body>
<FRAME>
<BODY BACKGROUND="skull.gif">
<IMG SRC="kflag.jpg" >
<P>

<A HREF="mappage.htm" target="_blank" onMouseOver= "on()" onMouseOut="off()"><IMG SRC="friendbut.bmp" NAME="nick"> </A>
<BR>
<A HREF="friends.htm" target="_blank" onMouseOver= "on1()" onMouseOut="off1()"><IMG SRC="galbut.bmp" NAME="gal"> </A>
<BR>
<A HREF="links2.htm" target="_blank" onMouseOver="on2()" onMouseOut="off2()"><IMG SRC="linkbut.bmp" NAME="lin"> </A>
<BR>
<A HREF="Games.htm" target="_blank"onMouseOver="on3()" onMouseOut="off3()"><IMG SRC="gambut.bmp" NAME="gam"></A>
<BR>
<A HREF="Downloads.htm" target="blank"onMouseOver="on4()" onMouseOut="off4()"><IMG SRC="downbut.bmp" NAME="dow"> </A>

Thanks for the help....:)

Borgtex
12-12-2002, 10:42 AM
You can find a lot of rollover scripts everywhere. A simple example:


<script>
function onoff(imgid,img)
{
document.images[imgid].src=img
}
</script>


<A HREF="mappage.htm" target="_blank" onMouseOver= "onoff('nick','friendbut.bmp1')" onMouseOut="onoff('nick','friendbut.bmp')"><IMG SRC="friendbut.bmp" NAME="nick"> </A>

<A HREF="friends.htm" target="_blank" onMouseOver= "onoff('gal','galbut1.bmp')" onMouseOut="onoff('gal','galtbut.bmp')"><IMG SRC="galbut.bmp" NAME="gal"> </A>


Hope that you're not really using bmp's for your rollover images :eek:

cheesebagpipe
12-12-2002, 04:02 PM
http://www.xs4all.nl/~ppk/js/function.html#arguments ;)

Nirckoh
12-12-2002, 04:55 PM
Thanks alot for the code.. :) .i just use the bmp coz they are just buttons...and im still new to this what wrong with the bmp
::confused:

Borgtex
12-12-2002, 06:27 PM
bmp: bad or no compression at all = Large files = Waste of bandwith & space = Your site is and seems slower.

Use gif or png for text & linear graphics and jpg for photos instead