Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

need help with moving image

0 views
Skip to first unread message

Doug Lindquist

unread,
Sep 20, 2002, 12:15:19 AM9/20/02
to
I know some basic javascript. I am trying to put a moving picture on
web site. I have found code for earlier NS and IE. But I can not find
any code that works for accessing the image in Mozilla. Any help would
be appreciated. Thanks

--
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/

Richard Cornford

unread,
Sep 22, 2002, 4:12:12 AM9/22/02
to
Doug Lindquist wrote in message <3D8AA0D7...@localnet.com>...

>I know some basic javascript. I am trying to put a moving picture on
>web site. I have found code for earlier NS and IE. But I can not find
>any code that works for accessing the image in Mozilla. Any help would
>be appreciated. Thanks


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.


0 new messages