Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What's wrong with this fadein?

Status
Not open for further replies.

vanbeugen

IS-IT--Management
Feb 4, 2005
62
NL
In the HTML below I want a div containing a text and an image to fade in after a preset time (in this case 2 seconds). The fadingin works but a little bit later there comes an error. What do I do wrong?

<html>

<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<meta name="generator" content="Adobe GoLive 4">
<title>Welcome to Adobe GoLive 4</title>


<script language="JavaScript"><!--

var isNS = document.layers?true:false;
var isIE = document.all?true:false;
var isDOM = document.getElementById?true:false;

function show(id)
{
if (isNS) document.layers[id].visibility = "show";
else if (isIE)
{
document.all[id].style.visibility="visible";
//de 100 geeft de doorzichtigheid aan.
setTimeout("doFadeIn('"+id+"',100)",1000);
}
else if (isDOM) document.getElementById(id).style.visibility="visible";
}

function hide(id)
{
if (isNS) document.layers[id].visibility = "hide";
else if (isIE)
{
// document.all[id].style.visibility="hidden";
setTimeout("doFadeOut('"+id+"',100)",1000)
}
else if (isDOM) document.getElementById(id).style.visibility="hidden";
}

function doFadeIn(fadeName,maxPct)
{
var fadeObj = document.all[fadeName]
if ((fadeObj.filters.alpha.opacity + 6) <= maxPct)
{
fadeObj.filters.alpha.opacity += 6;
setTimeout("doFadeIn('" + fadeObj.id + "'," + maxPct + ")",30)
}
else fadeObj.filters.alpha.opacity = maxPct;
}

function doFadeOut(fadeName,maxPct)
{
var fadeObj = document.all[fadeName]
if ((fadeObj.filters.alpha.opacity - 8) >= 0)
{
fadeObj.filters.alpha.opacity -= 8;
setTimeout("doFadeOut('" + fadeObj.id + "'," + maxPct + ")",30)
}
else fadeObj.filters.alpha.opacity = 0;
}

// -->
</script>


</head>

<body>

<div id="divtofade" style="visibility:hidden;">
Welcome
<img src='draaikolk.jpg' width="50" height="50" alt="">
</div>

<script language="javascript1.3">
<!--
setTimeout("show(\'divtofade\')",2000)
// -->
</script>

</body>

</html>
 
- What browser is it erroring in?

- What is the error?

- Do you really only want this script to work in IE? Why not upgrade it so it works in Firefox, Netscape, and Safari, too? (and remove the crappy v4 browser detection at the same time)

Hope this helps,
Dan




[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
It's erroring in IE6. The error is given in line 41. It says: 'filters.alpha.opacity' is empty or no object. Well, to be honest: I would be very happy to upgrade the script also to Firecfox and Safari (here in the Netherlands no one uses Netscape any more), but I wouldn-t know how to do that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top