FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Off-Screen Objects Javascript

 


pavlov2002
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 and in the javascript function that produces the image movement, but it doesn't work
Anybody can turn on the light?? Shocked

Thanks!


This is the Js File:

Code:
var timer1;

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function Chip(chipname,width,height){
 this.named=chipname;
 this.xx=(-495);
 this.yy=208;
 this.timer1=null;
}

function movechip(chipname){
if (document.getElementById){
eval("chip="+chipname);
 if (window.innerWidth || window.opera){

 pageY=window.pageYOffset;
     pageH=window.innerHeight;
    }
   else if (document.body){
pageY=iecompattest().scrollTop;
     pageH=iecompattest().offsetHeight;
    }


while(chip.xx<250){
   chip.xx=chip.xx+5;}
 if (chip.xx<=420)
  {
  chip.xx=chip.xx+5;
  }
  else
  chip.xx=chip.xx;
document.getElementById(chip.named).style.left=chip.xx+"px";



   chip.timer1=setTimeout("movechip('"+chip.named+"')",50);
  }
}
[/code]

Last edited by pavlov2002 on Fri Jul 20, 2007 3:32 am; edited 1 time in total
bladesage
I don't see anything in there about position...

Are you sure you set the element's position property to "absolute" first? They won't go anywhere unless it's set to either absolute or relative...in this case, I'd suggest absolute.

If you did, just say so...you gave almost no information at all besides that js file. Which, by the way, should be inside [code] blocks. They make it much easier to read through the code.
pavlov2002
All right... besides the js file I posted there are this html instructions in another html file:
Code:

var flyimage1
function pagestart(){
 flyimage1=new Chip("flyimage1",495,330);
movechip("flyimage1");
.......................
.............................................
....................................................
........................................................
<DIV ID="flyimage1" STYLE="position:absolute;  top: 208px; left:-495px;  width: 495px; height: 330px;  overflow: hidden;"><img src="images/1Resize.jpg" border=0 /></DIV>


I mean...the jpg moves alright, but the starting point is not off-screen as I wish, but it starts moving on-screen. I Don't know why

HELP!!!!!
bladesage
pavlov2002 wrote:
I mean...the jpg moves alright, but the starting point is not off-screen as I wish, but it starts moving on-screen.


THAT is useful information. It would have helped earlier.

Browsing the web a bit, I have found some scripts that begin from outside the left part of the window, but they all use positions like -60 or -70...I do understand why you need that exact number, though.

My only other suggestion at the moment would be to try a number closer to zero...but as that isn't exactly what you're after, I'm sort of out of ideas.
gerpg
why not just use the html marquee feature? 99% of people now have a browser capable of marquees and you can change speeds and direction etc. Plus it means people don't need to have javascript turned on.

Louis.
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.