Jump to content


Element fade in/out


8 replies to this topic

#1 Av-

    I Feel Left Out

  • Members
  • PipPipPipPip
  • 1,971 posts
  • Gender:Male
  • Location:10 ft. below sea level

Posted 29 September 2006 - 02:59 PM

alright, this is one of the most frustrating, time consuming, teeth grinding error, ive ever stumbled upon. And worst of all, its probably easy to fix :) but here it goes, im trying to make a div fade out with the following function.

<div id="Layer1"></div>
<div id="Layer2"></div>
<script>
var opa = 100;
function changeopa(id){
if(opa >= 0){
var mozopa = opa / 100;
document.getElementById(id).style.filter = 'alpha(opacity='+opa+')';
document.getElementById(id).style.MozOpacity = mozopa;
document.getElementById(id).style.opacity = mozopa;
opa -=5;
setTimeout("changeopa(id)", "25");
}
}
changeopa('Layer1');
</script>

It doesnt work, firefox and ie both claim that the variable id is undefined, HOWEVER when i change this

changeopa('Layer1');

to this

var id = 'Layer1';
changeopa(id);

it DOES work, wth???

please help... or suffer the consequences ;P

#2 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 29 September 2006 - 03:23 PM

I would just use the Effect.Appear and Effect.Fade objects with the scriptaculous library, much simpler. :)
Or you might need to Effect.Opacity object, I'm not quite 100% on what effect you are trying to achieve.

Are you trying to make it do this effect when the element is interacted with (like onclick, etc), or on page load? Because it would be best to place it in your head of the document, and have an event handler call the function.

#3 cheerio

    Young Padawan

  • Members
  • Pip
  • 246 posts
  • Gender:Male

Posted 29 September 2006 - 03:26 PM

setTimeout("changeopa('"+id+"')", "25");
I tested and it only seemed to work for me in firefox

#4 Av-

    I Feel Left Out

  • Members
  • PipPipPipPip
  • 1,971 posts
  • Gender:Male
  • Location:10 ft. below sea level

Posted 29 September 2006 - 04:31 PM

View Postcheerio, on Sep 29 2006, 08:25 PM, said:

setTimeout("changeopa('"+id+"')", "25");
I tested and it only seemed to work for me in firefox

thanks bud, that did the trick :)

told you it was an easy fix ;)

#5 cheerio

    Young Padawan

  • Members
  • Pip
  • 246 posts
  • Gender:Male

Posted 29 September 2006 - 07:09 PM

Prototype / Scriptaculous still rock!

#6 Av-

    I Feel Left Out

  • Members
  • PipPipPipPip
  • 1,971 posts
  • Gender:Male
  • Location:10 ft. below sea level

Posted 30 September 2006 - 07:52 AM

View PostDemonslay, on Sep 29 2006, 08:22 PM, said:

Are you trying to make it do this effect when the element is interacted with (like onclick, etc), or on page load? Because it would be best to place it in your head of the document, and have an event handler call the function.

i know, but this was just a test document, trying to get it to work.

View PostDemonslay, on Sep 29 2006, 08:22 PM, said:

I would just use the Effect.Appear and Effect.Fade objects with the scriptaculous library, much simpler. :P
Or you might need to Effect.Opacity object, I'm not quite 100% on what effect you are trying to achieve.


View Postcheerio, on Sep 30 2006, 12:09 AM, said:

Prototype / Scriptaculous still rock!

scriptaculous library????

#7 Chaos King

    Senior Programmer

  • P2L Staff
  • PipPipPip
  • 676 posts
  • Gender:Male
  • Location:Florida

Posted 30 September 2006 - 09:49 AM

Google?????

http://www.google.com/search?hl=en&q=s...G=Google+Search

#8 Av-

    I Feel Left Out

  • Members
  • PipPipPipPip
  • 1,971 posts
  • Gender:Male
  • Location:10 ft. below sea level

Posted 01 October 2006 - 07:51 AM

Thanks??????

Scriptacolous does the job, but way too much code for a simple effect imo...

#9 Chaos King

    Senior Programmer

  • P2L Staff
  • PipPipPip
  • 676 posts
  • Gender:Male
  • Location:Florida

Posted 01 October 2006 - 08:18 AM

That is what you get for cross browser compatibility. Scriptaculous is not only one effect, it is an entire library of visual effects, not one and you can delete some out of them that you arn't going to use if you want to make the file smaller. But just make sure you know what you are doing :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users