Home / Free JavaScripts / Special Effects With Background / Here

JavaScript Kit

Cut & Paste Fade in, fade out!

Credit: Isaac Lee

Description: You've probably seen fade-in scripts, fade-out scripts, but this is among the first to combine the two to create one great combo effect! The script fades in when the user enters the page, and out when they exit.

Example: Try existing this page to see the second half of the effect.

Directions:

Step 1: Insert the following code into the <head> section of your page:

Step 2: Add the below event handler into the <body> tag itself, like this:

<body onLoad="fade(0, 0, 0, 255, 255, 255, 64)" onUnload="fade(255, 255, 255, 0, 0, 0, 64)">

By default, the script fades from black-to-white upon enter, and white-to-black upon exit. If your page contains a black background, you want those settings reversed for the script. Just swap the values inside the two fade() functions above (255,255...).


[an error occurred while processing this directive]

Copyright 1997-2014 JavaScript Kit. NO PART may be reproduced without author's permission.