mystx
10-18-2003, 07:18 PM
Hi!
This is the situation! I'm trying to make a script that would fade in/out a DIV box.
function setOpacity(objectId,objectOpacity) {
if (document.all){
document.all(objectId).filters.alpha.opacity = objectOpacity
} else if (!document.all && document.getElementById) {
document.getElementById(objectId).style.MozOpacity = objectOpacity/100
}
}
function fadeDiv(id) {
divOpacity = divOpacity - oAmount
if (divOpacity > 0) {
setOpacity(id,divOpacity)
setTimeout("fadeDiv()",1)
}
}
and in the body is:
<div id="bigDiv" class="div1"></div>
<button class="theButton" onclick="fadeDiv('bigDiv')">Test</button>
Now, the goal is, when I click the "Test" button, function fadeDiv() is called and the DIV id is passed to it.
In the fadeDiv() function you can see that there is a call to setOpacity() function. Now here comes the problem: that variable "id" in setOpacity(id,divOpacity) is supposed to be passed to function setOpacity() and that variable is really passed but I allways get error document.all[...].filters is null or not an object.I suspect there's a problem with passing the variable to setOpacity() function.
I'm rather new to this so please help me out if you can. Thanx!
This is the situation! I'm trying to make a script that would fade in/out a DIV box.
function setOpacity(objectId,objectOpacity) {
if (document.all){
document.all(objectId).filters.alpha.opacity = objectOpacity
} else if (!document.all && document.getElementById) {
document.getElementById(objectId).style.MozOpacity = objectOpacity/100
}
}
function fadeDiv(id) {
divOpacity = divOpacity - oAmount
if (divOpacity > 0) {
setOpacity(id,divOpacity)
setTimeout("fadeDiv()",1)
}
}
and in the body is:
<div id="bigDiv" class="div1"></div>
<button class="theButton" onclick="fadeDiv('bigDiv')">Test</button>
Now, the goal is, when I click the "Test" button, function fadeDiv() is called and the DIV id is passed to it.
In the fadeDiv() function you can see that there is a call to setOpacity() function. Now here comes the problem: that variable "id" in setOpacity(id,divOpacity) is supposed to be passed to function setOpacity() and that variable is really passed but I allways get error document.all[...].filters is null or not an object.I suspect there's a problem with passing the variable to setOpacity() function.
I'm rather new to this so please help me out if you can. Thanx!