javacript code not working in firefox but works fine in IE

Reply

Join Date: Apr 2006
Posts: 3
Reputation: V KUMAR is an unknown quantity at this point 
Solved Threads: 0
V KUMAR V KUMAR is offline Offline
Newbie Poster

javacript code not working in firefox but works fine in IE

 
0
  #1
Jan 31st, 2007
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);
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 1,181
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Solved Threads: 67
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: javacript code not working in firefox but works fine in IE

 
0
  #2
Jan 31st, 2007
offsetWidth is not supported in all browsers
HTML and CSS Syntax (Toggle Plain Text)
  1. var x,y;
  2. var test1 = document.body.scrollHeight;
  3. var test2 = document.body.offsetHeight
  4. if (test1 > test2) // all but Explorer Mac
  5. {
  6. x = document.body.scrollWidth;
  7. y = document.body.scrollHeight;
  8. }
  9. else // Explorer Mac;
  10. //would also work in Explorer 6 Strict, Mozilla and Safari
  11. {
  12. x = document.body.offsetWidth;
  13. y = document.body.offsetHeight;
  14. }
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the HTML and CSS Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC