Cory_Larson04
asked on
Fading out div content onload
I have the following script that shows a "page loading" message while the page is loading. What I would like it to do is fade out after the page has loaded instead of just disappearing. I have tried applying styles and filters (blendTrans) but i get errors. Here is the code:
<SCRIPT LANGUAGE="JavaScript">
ver = navigator.appVersion.subst ring(0,1)
if (ver >= 4)
{
document.write('<DIV ID="cache" align="center"><br>');
document.write('<TABLE WIDTH=95% height="90%" class="heading" bgcolor="#ecedee"><TR><TD ALIGN=center VALIGN=middle class="normaltext">');
document.write('<b>The page you have requested is loading...please wait.</b></TD></TR></TABLE >');
document.write('</DIV>');
var navi = (navigator.appName == "Netscape" && parseInt(navigator.appVers ion) >= 4);
var HIDDEN = (navi) ? 'hide' : 'hidden';
var VISIBLE = (navi) ? 'show' : 'visible';
var cache = (navi) ? document.cache : document.all.cache.style;
largeur = screen.width;
cache.left = Math.round(0);
cache.visibility = VISIBLE;
}
function cacheOff()
{
if (ver >= 4)
{
cache.visibility = HIDDEN;
}
}
window.onload=cacheOff;
</SCRIPT>
If anybody could help me out that would be great!
<SCRIPT LANGUAGE="JavaScript">
ver = navigator.appVersion.subst
if (ver >= 4)
{
document.write('<DIV ID="cache" align="center"><br>');
document.write('<TABLE WIDTH=95% height="90%" class="heading" bgcolor="#ecedee"><TR><TD ALIGN=center VALIGN=middle class="normaltext">');
document.write('<b>The page you have requested is loading...please wait.</b></TD></TR></TABLE
document.write('</DIV>');
var navi = (navigator.appName == "Netscape" && parseInt(navigator.appVers
var HIDDEN = (navi) ? 'hide' : 'hidden';
var VISIBLE = (navi) ? 'show' : 'visible';
var cache = (navi) ? document.cache : document.all.cache.style;
largeur = screen.width;
cache.left = Math.round(0);
cache.visibility = VISIBLE;
}
function cacheOff()
{
if (ver >= 4)
{
cache.visibility = HIDDEN;
}
}
window.onload=cacheOff;
</SCRIPT>
If anybody could help me out that would be great!
ASKER
Yes, something like that. This is the modified code that gets errors (maybe you will see what I'm getting at):
<SCRIPT LANGUAGE="JavaScript">
ver = navigator.appVersion.subst ring(0,1)
if (ver >= 4)
{
document.write('<DIV ID="cache" align="center"><br>');
document.write('<TABLE WIDTH=95% height="90%" class="heading" bgcolor="#ecedee"><TR><TD ALIGN=center VALIGN=middle class="normaltext">');
document.write('<b>The page you have requested is loading...please wait.</b></TD></TR></TABLE >');
document.write('</DIV>');
var navi = (navigator.appName == "Netscape" && parseInt(navigator.appVers ion) >= 4);
var HIDDEN = (navi) ? 'hide' : 'hidden';
var VISIBLE = (navi) ? 'show' : 'visible';
var cache = (navi) ? document.cache : document.all.cache.style;
largeur = screen.width;
cache.left = Math.round(0);
cache.visibility = VISIBLE;
}
function cacheOff()
{
if (ver >= 4)
{
cache.style.filter="blendT rans(durat ion=0.5)";
cache.filters.blendTrans.a pply();
cache.style.visibility = HIDDEN;
cache.filters.blendTrans.p lay();
}
}
window.onload=cacheOff;
</SCRIPT>
I get a ['cache.style' is null or not an object] error.
Hopefully this helps.
<SCRIPT LANGUAGE="JavaScript">
ver = navigator.appVersion.subst
if (ver >= 4)
{
document.write('<DIV ID="cache" align="center"><br>');
document.write('<TABLE WIDTH=95% height="90%" class="heading" bgcolor="#ecedee"><TR><TD ALIGN=center VALIGN=middle class="normaltext">');
document.write('<b>The page you have requested is loading...please wait.</b></TD></TR></TABLE
document.write('</DIV>');
var navi = (navigator.appName == "Netscape" && parseInt(navigator.appVers
var HIDDEN = (navi) ? 'hide' : 'hidden';
var VISIBLE = (navi) ? 'show' : 'visible';
var cache = (navi) ? document.cache : document.all.cache.style;
largeur = screen.width;
cache.left = Math.round(0);
cache.visibility = VISIBLE;
}
function cacheOff()
{
if (ver >= 4)
{
cache.style.filter="blendT
cache.filters.blendTrans.a
cache.style.visibility = HIDDEN;
cache.filters.blendTrans.p
}
}
window.onload=cacheOff;
</SCRIPT>
I get a ['cache.style' is null or not an object] error.
Hopefully this helps.
ASKER
whoops, move
cache.filters.blendTrans.p lay();
to before
cache.style.visibility = HIDDEN;
cache.filters.blendTrans.p
to before
cache.style.visibility = HIDDEN;
ASKER
What I need is a script that changes the <div>'s opacity from 100 to 0, revealing the page content.
substitute
document.all.cache.style
with
document.getElementById('c ache')
and it works on my machine
although I am almost sure that you would want to increase the duration of blendTrans
document.all.cache.style
with
document.getElementById('c
and it works on my machine
although I am almost sure that you would want to increase the duration of blendTrans
ASKER
I changed the line that you said, but the effect is still not playing on my machine. I have been playing around with looping the <div>'s opacity down to zero, but it seems to jump straight from 100 to 0 with no effect. In the meantime, I'm gonna go look for some other effects scripts and maybe just write this one over from scratch. Thanks
I have found the solution!!!
Add this style="width:900"
document.write('<DIV ID="cache" align="center" style="width:900"><br>');
I have put 900 but put whatever you want
it works now
Add this style="width:900"
document.write('<DIV ID="cache" align="center" style="width:900"><br>');
I have put 900 but put whatever you want
it works now
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Alright...after a couple hours of research and writing code, I have achieved the effect I was looking for. You can see the effect in action at http://www.sourcecodevault.com or copy and paste this script into the <head> section of any page you want. Thanks for your efforts hexagon47!
Here is the script:
<script language="JavaScript">
ver = navigator.appVersion.subst ring(0,1);
if (ver >= 4) {
document.write('<div id="cache" style="filter:alpha(opacit y=50); width:100%"><br>');
document.write('<table width="95%" height="93%" class="heading" bgcolor="#ecedee" align="center"><tr><td align="center" class="grey">');
document.write('<b><h3>The page you have requested is loading...please wait.</h3></b></td></tr></ table>');
document.write('</div>');
var navi = (navigator.appName == "Netscape" && parseInt(navigator.appVers ion) >= 4);
var HIDDEN = (navi) ? 'hide' : 'hidden';
var VISIBLE = (navi) ? 'show' : 'visible';
var cache = (navi) ? document.cache : document.all.cache;
largeur = screen.width;
cache.style.left = Math.round(0);
cache.style.visibility = VISIBLE;
}
var count = 50;
function cacheOff() {
if (ver >= 4) {
count-=10
if (count >= 0) {
cache.filters("alpha").opa city = count;
timer=setTimeout("cacheOff ()",0)
}
else {
clearTimeout(timer);
cache.style.visibility = HIDDEN;
}
}
}
window.onload=cacheOff;
</script>
Here is the script:
<script language="JavaScript">
ver = navigator.appVersion.subst
if (ver >= 4) {
document.write('<div id="cache" style="filter:alpha(opacit
document.write('<table width="95%" height="93%" class="heading" bgcolor="#ecedee" align="center"><tr><td align="center" class="grey">');
document.write('<b><h3>The
document.write('</div>');
var navi = (navigator.appName == "Netscape" && parseInt(navigator.appVers
var HIDDEN = (navi) ? 'hide' : 'hidden';
var VISIBLE = (navi) ? 'show' : 'visible';
var cache = (navi) ? document.cache : document.all.cache;
largeur = screen.width;
cache.style.left = Math.round(0);
cache.style.visibility = VISIBLE;
}
var count = 50;
function cacheOff() {
if (ver >= 4) {
count-=10
if (count >= 0) {
cache.filters("alpha").opa
timer=setTimeout("cacheOff
}
else {
clearTimeout(timer);
cache.style.visibility = HIDDEN;
}
}
}
window.onload=cacheOff;
</script>
<SCRIPT>
var bToggle = 0;
function fnToggle() {
oDiv.filters[0].Apply();
// After setting Apply, changes to the oDiv object
// are not displayed until Play is called.
if (bToggle) {
bToggle = 0;
oDiv.style.backgroundColor
else {
bToggle = 1;
oDiv.style.backgroundColor
oDiv.filters[0].Play();
}
</SCRIPT>
<BUTTON onclick="fnToggle()">Toggl
<DIV ID="oDiv" STYLE="height:250px; width:250px; background-color: #000000;
filter:progid:DXImageTrans
duration=2);">
</DIV>