Off-Screen Moving Objects Javascript - possible?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pavlov
    New Member
    • Jul 2007
    • 1

    Off-Screen Moving Objects Javascript - possible?

    Hello everybody.
    I've this problem: I'm making a jpg moving horizontally from left to right in my page. I'd like to make it start moving from the left off-screen side. I tried using position negative values either defining the <style> of the img object or in the Javascript function that produces the image movement, but it doesn't work. The starting point from the images is always on screen.
    Anybody can turn on the light??

    Thanks!


    This is the Js File:

    [CODE=javascript]var timer1;

    function iecompattest(){
    return (document.compa tMode && document.compat Mode!="BackComp at")? document.docume ntElement : document.body
    }

    function Chip(chipname,w idth,height){
    this.named=chip name;
    this.xx=(-495);
    this.yy=208;
    this.timer1=nul l;
    }

    function movechip(chipna me){
    if (document.getEl ementById){
    eval("chip="+ch ipname);
    if (window.innerWi dth || window.opera){

    pageY=window.pa geYOffset;
    pageH=window.in nerHeight;
    }
    else if (document.body) {
    pageY=iecompatt est().scrollTop ;
    pageH=iecompatt est().offsetHei ght;
    }


    while(chip.xx<2 50){
    chip.xx=chip.xx +5;}
    if (chip.xx<=420)
    {
    chip.xx=chip.xx +5;
    }
    else
    chip.xx=chip.xx ;
    document.getEle mentById(chip.n amed).style.lef t=chip.xx+"px";



    chip.timer1=set Timeout("movech ip('"+chip.name d+"')",50);
    }[/CODE]
    Last edited by gits; Jul 19 '07, 06:37 PM. Reason: added CODE-tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    [CODE=javascript]while(chip.xx<2 50){
    chip.xx=chip.xx +5;}[/CODE]would loop until 250, so xx can never be negative.

    Comment

    Working...