Click to See Complete Forum and Search --> : Need help with a function


Doobey
10-18-2005, 07:49 AM
Hi this is my script, I wonder why it says that:
"fadein is not an object" & "fadeout is not an object" when I take the mouse over the image!
Anyone have an idea why?

<html>
<body>

<script type="text/javascript">


function imageopacity()
{

var fadein = this.filters.alpha.opacity=100;
var fadeout = this.filters.alpha.opacity=50;

document.write("<img style=filter:alpha(opacity=50) onMouseOver=fadein onMouseOut=fadeout src='logotest.gif'>")
}

imageopacity()

</script>

<img style=filter:alpha(opacity=50) src="/jorgen/logotest.gif">

</body>
</html>

Doobey
10-18-2005, 08:11 AM
damn it was wrong script, here is the right one:

<html>
<body>

<script type="text/javascript">


function imageopacity()
{

var fadein = ("object.filters.alpha.opacity=100");
var fadeout = ("object.filters.alpha.opacity=50");

document.write("<img style=filter:alpha(opacity=50) onMouseOver=fadein onMouseOut=fadeout src='http://www.vaffel.org/jorgen/logotest.gif'>")
}

imageopacity()

</script>

</body>
</html>

A1ien51
10-18-2005, 08:13 AM
function fade(obj,amt){
obj.filters.alpha.opacity = amt;
}

document.write("<img style=filter:alpha(opacity=50) onMouseOver='fade(this,100)' onMouseOut='fade(this,50)' src='logotest.gif'>")


One thing you are going to see is this will not work in all browsers....

Eric

Doobey
10-18-2005, 08:14 AM
I know it only will work in IE, but though IE is the most common browser, within noobs ;) thnx anyway

Doobey
10-18-2005, 08:24 AM
is it possible to get the image opacity to change a bit slower, like fadespeed() or something?

A1ien51
10-18-2005, 08:26 AM
For yours, you need to do

....onMouseOver=" + fadein + "....

since you are dealing with a variable holding a string.

Here is a quick script for you:


<html>
<head>
<style type="text/css">
.full{
opacity: 1;
filter: alpha(opacity=100);
}
.half{
opacity: .5;
filter: alpha(opacity=50);
}
</style>
<script type="text/javascript">
function fade(obj,strClass){
obj.className = strClass;
}
</script>
</head>
<body>
<img src="83.gif" class="half" onmouseover="fade(this,'full')" onmouseout="fade(this,'half')" />
</body>
</html>


It can be done a lot of different ways.
Eric

A1ien51
10-18-2005, 08:42 AM
http://www.dynamicdrive.com/dynamicindex4/highlightgrad.htm