MJ
asked on
Make inner.html, more compatible???
I have this code(partial):
-------------------------- --
function updateBar(change) {
ofTotal += change;
if(ofTotal <= 0){
var pbarw = 0;
}else{
var pbarw = Math.round(barWidth * ofTotal);
if (pbarw > barWidth){pbarw = barWidth;}
}
document.getElementById('p ercentNume ric').inne rHTML = Math.round(pbarw *100/barWidth);//need to be more compatible
getObj(progressBarId).styl e.width = pbarw;
}
function getObj(objid) {
if (document.getElementById(o bjid)) {
return(document.getElement ById(objid ));
} else if (document.getElementsByNam e(objid)[0 ]) {
return(document.getElement sByName(ob jid)[0]);
} else if (document.all[objid]) {
return(document.all[objid] );
} else if (document.layers[objid]) {
return(document.layers[obj id]);
} else {
return false;
}
}
//-->
</script>
</head>
<body onload="setBar();updateBar (0);">
<div id="totalBar" style="border:1px solid black;"><div id="progressBar"></div></d iv>
<div id="percentNumeric">The value is:</div>
</body>
-------------------------- -------
How do I make this line more browser compatible like the line below it???
document.getElementById('p ercentNume ric').inne rHTML =...
--------------------------
function updateBar(change) {
ofTotal += change;
if(ofTotal <= 0){
var pbarw = 0;
}else{
var pbarw = Math.round(barWidth * ofTotal);
if (pbarw > barWidth){pbarw = barWidth;}
}
document.getElementById('p
getObj(progressBarId).styl
}
function getObj(objid) {
if (document.getElementById(o
return(document.getElement
} else if (document.getElementsByNam
return(document.getElement
} else if (document.all[objid]) {
return(document.all[objid]
} else if (document.layers[objid]) {
return(document.layers[obj
} else {
return false;
}
}
//-->
</script>
</head>
<body onload="setBar();updateBar
<div id="totalBar" style="border:1px solid black;"><div id="progressBar"></div></d
<div id="percentNumeric">The value is:</div>
</body>
--------------------------
How do I make this line more browser compatible like the line below it???
document.getElementById('p
Like this:
getObj('percentNumeric').i nnerHTML = Math.round(pbarw *100/barWidth);
getObj('percentNumeric').i
ASKER
Tried that but doesn't work because of index reference in function
What index are you talking about?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
...if (document.getElementsByNam e(objid)[0 ]) {..... this part will always be ignored by --> if(document.getElementById )
document.getElementById('p