Wrox Programmer Forums
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 21st, 2005, 05:24 AM
Registered User
Join Date: Feb 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default animation problems

Hallo.. I have this code here and I'm trying to make it work in mozilla but it doesn't work. It's an animation that moves from left to right on the screen it does work in explorer.Is there anyone who can help me?What do I need to add?

<script language="Javascript1.2">

var objRef, steg=6; position=10
function Init() {
    if (document.layers)
        objRef = document.layers.bild;
        objRef = document.all.bild.style;

function Flytta() {
    if (position>900)
    else if (position<10)
    objRef.left = position;
<body onLoad="Init()">

Old February 22nd, 2005, 12:32 PM
Registered User
Join Date: Feb 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts

Hi Chrissy,

This uses getElementById to move the div, you'll need to check compatibility with
your target browsers. If you have to have your page work with layers you'll have
to post a test link or more source code for us to help you.

You'll have to put your own image in this page of course.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  <title>Move Along Little Doggie</title>

var move_div;
var tm;
var pos;
var screenH = screen.availHeight;
var screenW = screen.availWidth;
var myDog = new Image();
myDog.src = "images/doggie.jpg";

function init(){
move_div = document.getElementById('anim');
move_div.style.top = 200;
pos = -80;
tm = setInterval('moveDiv()',120);

function moveDiv(){
if(pos > (screenW + 50)){
move_div.style.visibility = 'visible';
move_div.style.left = pos;
pos += 15;
window.onload = init;
<div id="anim" style="left:0; top:0; position: absolute; visibility: hidden;">
<img src="images/doggie.jpg" width="150" height="90" alt="" border="0" align="">



Similar Threads
Thread Thread Starter Forum Replies Last Post
Image Animation Andraw Java GUI 0 October 9th, 2008 08:51 PM
problem with animation 132591 Java Basics 0 December 8th, 2006 06:45 PM
Text Animation flash2004 Flash (all versions) 2 May 18th, 2005 12:41 AM
Animation Control JelfMaria VB How-To 2 March 14th, 2005 12:11 AM
Animation pallone Javascript How-To 9 February 2nd, 2005 03:17 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.