Hi,
actually my intentions were to have a fast fadeout + fadein effect
every time the user clicks on a link to go to another page of the
site. I thought I could get this simply by handling the onload and
onunload events of the body tag, since they are called everytime the
browser moves from one page to another:
html:
<body onload="javascript:onLoadPage();"
onunload="javascript:onUnloadPage();" ...
javascript:
function onLoadPage() {
Effect.Appear('main', { duration: 0.5 });
}
function onUnloadPage() {
Effect.Fade('main', { duration: 0.5 });
}
The fadein effect (Effect.Appear) called on the onload event works
perfectly, while the fadeout doesn't, exactely because of the reason
you mentioned.
I found a solution in order to achieve the wanted effect transition.
I have completely discarded the onunload event of the body tag, and I
have written a javascript function to be called everytime the user
clicks a link. This function first invokes the fadeout effect, and
when the effect is over, it opens the new link. Here it is:
html body tag:
<body id="body" onload="javascript:onLoadPage();" ...
html link example:
<a href="home.html" onclick="return openPage(this.href);">Home</a>
javascript
function onLoadPage() {
Effect.Appear('main', { duration: 0.5 });
}
function openPage(url) {
new Effect.Fade(
'main',
{
duration: 0.5,
afterFinish: function() { window.location.href = url; }
}
);
return false;
}
Now it works as expected, but I don't like very much this solution
since for every link the openPage funtion invocation has to be added
(onclick="return openPage(this.href);")
I preferred to handle all this in a more automatic way :-)
Thanks