DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   HTML and CSS (http://www.daniweb.com/forums/forum143.html)
-   -   javacript code not working in firefox but works fine in IE (http://www.daniweb.com/forums/thread68772.html)

V KUMAR Jan 31st, 2007 9:06 am
javacript code not working in firefox but works fine in IE
 
var head = headElement.firstChild;
var headTable = headElement.firstChild;
var body = bodyElement.firstChild;
var bodyTable = bodyElement.firstChild;

var a = body.offsetWidth;
alert(a);
var scrollBarWidth = body.offsetWidth - body.clientWidth;
headTable.style.width = Math.max(0, bodyTable.offsetWidth + scrollBarWidth);

hollystyles Jan 31st, 2007 10:43 am
Re: javacript code not working in firefox but works fine in IE
 
offsetWidth is not supported in all browsers
var x,y;
var test1 = document.body.scrollHeight;
var test2 = document.body.offsetHeight
if (test1 > test2) // all but Explorer Mac
{
        x = document.body.scrollWidth;
        y = document.body.scrollHeight;
}
else // Explorer Mac;
    //would also work in Explorer 6 Strict, Mozilla and Safari
{
        x = document.body.offsetWidth;
        y = document.body.offsetHeight;
}


All times are GMT -4. The time now is 5:58 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC