jkawah
asked on
Style property is null even after setting at least one setting
I keep getting: "obj.style" is null or not an object error even after I have executed the following code:
if (document.getElementById){
document.getElementById("o bj")
obj.style.fontSize='8pt'
obj.style.fontFamily='Aria l'
}
alert("obj.style: " + obj.style)
if (document.getElementById){
document.getElementById("o
obj.style.fontSize='8pt'
obj.style.fontFamily='Aria
}
alert("obj.style: " + obj.style)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ok.
Either way, you're not setting the obj to anything. If it's declared globally, you'll still have to set it, like this:
if (document.getElementById){
obj = document.getElementById("o bj")
obj.style.fontSize='8pt'
obj.style.fontFamily='Aria l'
}
Either way, you're not setting the obj to anything. If it's declared globally, you'll still have to set it, like this:
if (document.getElementById){
obj = document.getElementById("o
obj.style.fontSize='8pt'
obj.style.fontFamily='Aria
}
ASKER
Yes, I forgot to type in my original question: menuobj = document.getElementById('o bj'). But it is was like that in my code. Actually, here's exactly what was in the code (I modified it to make it generic):
menuobj=ie4? document.all.popmenu : ns6? document.getElementById("p opmenu") : ns4? document.popmenu : ""
with the following variables defined globally, before the function that uses the above line (all this courtesy of Dynamic Drive):
var ie4=document.all
var ns6=document.getElementByI d&&!docume nt.all
var ns4=document.layers
var menuobj
menuobj=ie4? document.all.popmenu : ns6? document.getElementById("p
with the following variables defined globally, before the function that uses the above line (all this courtesy of Dynamic Drive):
var ie4=document.all
var ns6=document.getElementByI
var ns4=document.layers
var menuobj
ASKER