Click to See Complete Forum and Search --> : What is wrong with this script?


justin001
10-07-2003, 04:44 AM
function getFullPos(pObj,pAxis)
{
("true"=="true")?{if(pAxis=="y"){var prop="offsetHeight"};else{var prop="offsetWidth"}}:(alert("Bad"));
alert(prop);
for (var i=pObj;i.id!="myBody";i=i.offsetParent);
}

Apart from the inefficiently written condition, please can someone let me know what's wrong here?

Thanks,
Justin

Charles
10-07-2003, 05:15 AM
function getFullPos(pObj,pAxis) {
var prop = pAxis == 'y' ? 'offsetHeight' : 'offsetWidth';
alert(prop);
for (var i=pObj;i.id!="myBody";i=i.offsetParent);
}

justin001
10-07-2003, 05:21 AM
Thanks for the reply Charles. Your script makes things much simpler. I had alterior motives for creating the script though, I wanted to see if the statement involving (cond)?doiftrue:doiffalse could handle complexitites like multiple statements within {} brackets. Was I wrong in assuming it could.

Cheers,
Justin