tags:

views:

27

answers:

1
function VisibleDiv(obj) {
if (obj == BaseLog) {
var objStyle = document.getElementById('DivCalls').style;
if (objStyle.display == "block")
objStyle.display = "none";
else
objStyle.display = "block";
}
else if (obj == ViewReports) {
var objStyle = document.getElementById('DivReports').style;
if (objStyle.display == "block")
objStyle.display = "none";
else
objStyle.display = "block";
}
else if (obj ==Management) {
var objStyle = document.getElementById('DivManage').style;
if (objStyle.display == "block")
objStyle.display = "none";
else
objStyle.display = "block";
}

<a href="#" id="BaseLog" class="TextHeader" onclick="VisibleDiv(this)">Base Log </a>

in the above code is working in IE but not working in mozilla 3.6. I have checked that obj==BaseLog is not working in the above code. I have tried many options like

event.srcelement
window.event.srcelement

but all in vain. when I debug the code ,I found that obj is having complete value for IE but the same obj is having all the names .ie. the name of tag,id and class for "Base Log" seperated by #. i.e a#BaseLog#TextHeader# Please suggest what shoud I do?

+5  A: 

Either use

if (obj.id == 'BaseLog')

or

if (obj == getElementById('BaseLog'))

In IE, if an HTML element has id X, then in script the global variable X will be assigned to that element. This is not the case for many other browsers, which is also why it works in IE but not Firefox.

KennyTM
yup, this really worked!
@anand: Please tick the check mark, so we can see that this question has an accepted answer, see http://meta.stackoverflow.com/questions/5234/how-does-accepting-an-answer-work/5235#5235 (there's a reputation benefit for you, too ;)
Marcel Korpel