View Full Version : Uninitialized "temp" array in Cross Browser Marquee I

01-22-2014, 09:37 PM
1) Script Title: Cross Browser Marquee I

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex2/cmarquee.htm

3) Describe problem:

The "temp" variable in the "populate()" function appears to be uninitialized. It is used only once in the following line where the "offsetWidth" element is being selected for "actualwidth" in the event the "all" element of "document" is not null:

actualwidth=document.all? temp.offsetWidth : document.getElementById("temp").offsetWidth;

Is this a debugging artifact? What work around do you suggest?


Aza D. Oberman
January 22, 2014

01-22-2014, 10:09 PM
No it's not for any debugging, but it is sloppy and outdated. You can make it merely outdated by changing that line to:

actualwidth=document.all? document.all['temp'].offsetWidth : document.getElementById("temp").offsetWidth;

Or, since IE 4 and less are rarely if ever used any longer, make it up to date by changing it to:

actualwidth = document.getElementById("temp").offsetWidth;

01-23-2014, 03:06 AM
Thanks John. I'd figured that out plus a bunch of other diddles to make nice with some of the handhelds.

The clearly non-random sample from our SSI logs shows a remarkable number of ancient and mystery browsers. Might just as well have the pages render on as many as possible.