--
Doug Lindquist
Bradford First Free Methodist Church
Youth For Christ of the Bradford Area
bff...@localnet.com
do...@email.com
http://members.localnet.com/~bradffmc/
Images that move are usually placed in absolutely positioned DIV tags.
Old code that does not work with Mozilla or Netscape 6+ usually accesses
the DIV tags with 'document.layers' on Netscape 4 and 'document.all' on
IE. Mozilla/Netscape 6+ does not have either of these collections,
instead, it is usual to use the 'document.getElementById' function
(ensuring that the DIV has an ID). 'getElementById' is a standard DOM
function and is present on IE 5+ Mozilla/Netscape 6+ and Opera 5+ (at
least).
In the older Netscape 4/IE 4 code, a branch would usually be made in
order to get the object on which the 'left' and 'top' values would be
set to position the DIV. On Netscape 4 that object is the DIV itself, on
IE 4 it was the 'style' object that is a property of the DIV.
Mozilla/Netscape 6+ also use the 'style' object for positioning (as do
Opera and IE 5+).
Netscape 4/IE 4 code to locate the DIV (IDed as 'myDiv' in this case)
might have looked like this:
var obj; //object to be positioned
if(document.layers){
obj = document.layers['myDiv'];
}else if(document.all){
obj.document.all.item('myDiv').style;
}else{
obj = null; //can't do positioning
}
if(obj){
obj.top = topPosition;
obj.left = leftPosition;
}else{
; //do nothing (this else can be omitted)
}
Similar code for Mozilla/Netscape 6+ and other DOM browsers like Opera
might be like this:
var obj; //object to be positioned
if(document.getElementById){ //IE5+, Moz/Net6+, Op5+ and others
obj = document.getElementById('myDiv').style;
}else if(document.all){ //IE 4
obj = document.all.item('myDiv').style;
}else if(document.layers){ //Netscape 4
obj = document.layers['myDiv'];
}else{
obj = null; //can't do positioning
}
if(obj){
obj.top = topPosition;
obj.left = leftPosition;
}else{
; //do nothing (this else can be omitted)
}
HTH
Richard.