My client wanted to make a transition between pages. I thought it would be difficult to do, but with help of Scriptaculous effects and Prototype's $$() function it turned out to be pretty simple.
The method I used is easy to use, unobtrusive and needs only one element which usually is already in the code – main div surrounding all page content.
Add Javascript libraries
- Download the linkToFade.js file
- Add Prototype, Scriptaculous and linkToFade files
<script type="text/javascript" src="scriptaculous/lib/prototype.js"></script>
<script type="text/javascript" src="scriptaculous/src/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="linkToFade.js"></script>
Write the (X)HTML
It's normal HTML one would use for the page. Just the link needs to have a class named „fade“
<div id='page'>
<!-- ... -->
<a href='standard_link' class='fade'>Link</a>
<!-- ... -->
</div>
Initiate linkToFade functions
Add following after the (X)HTML code given above:
<script type='text/javascript' language='javascript'>
Event.observe(window,'load',
function () {
// inititate the link to fade functions
initiateLinkToFade();
}
);
</script>
We've got the linkToFade functionality. To make the page also appear on load one has to add this just before initiating the link to fade:
// make the page appear on load
$('page').hide();
new Effect.Appear('page');
// inititate the link to fade functions
initiateLinkToFade();
That's it! Grab your linkToFade.js and share the news below:









Comments
AG said Friday its drug Tarceva was shown to extend the lives of patients with lung cancer without their tumor growing when given immediately after chemotherapy.wow goldThe data could help expand sales of the drug, which, until now, could be prescribed only to patients who had failed previous treatment.
Thank you for telling me so many useful things.
great!but not working in IE7
great!but not working in IE7
The averages are higher after having opened relatively quietly. Fed Chairman Bernanke is speaking before the House Budget Committee, and in his prepared remarks stated that he sees some encouraging signs from the recent government measures that are supporting the markets. He also said he's in favor of a second stimulus to support the markets, but that it should be aimed at spurring credit access and it must limit the effect on the structural budget deficit. The Chairman also said he sees some risk of a protracted slowdown as housing remains depressed and auto sales have dropped sharply.
Hi Ken
Good point - everything which needs to fade out needs to be within #page block.
You have a great piece of coding and it should be more widely used. The only confusing thing that I noticed and it took me a while to figure out…
You never say you must have a div that wraps around the whole content of your webpage… in your caseotherwise the script init will not work as it specifically looks for ‚page‘. As shown below.
// make the page appear on load $(‚page‘).hide(); new Effect.Appear(‚page‘);
Either make a new div named ‚page‘ or add your own and change the ID reference in the Init script.
Otherwise, good work!
@Ryan I don't know – Your website is not working…
What am I doing wrong?
http:// www .ishowpro.com/Exhibitors/booth_test.aspx
>> edited by Piotr to remove 404 link from the page
Post new comment