By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,970 Members | 1,669 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,970 IT Pros & Developers. It's quick & easy.

Moving div tags in Firefox with setInterval

P: 17
I am working on a site where we are doing some experamental Javascript and Flash actionscript. Basicly, at a certain point the flash movie tells the javascript function on the page to move the div that conatins the flash movie off the page to the right.

I finally got everything to work, by using window.setInterval(); to start calling a function that moves the div off the screen by 5px untill it reached 1000 px.

The problem is that in Firefox the div will stop in place and not move but when you click another window, you can see it moving in the background fine. This is really weird.

I was wondering if there is a better way than changing the x coord of a div other than the style.left = with css?

not sure if this helps but here is the code:
Expand|Select|Wrap|Line Numbers
  1. var b         = browserCheck();
  2.     var moveID     = 0;
  3.     var win     = window.self;
  4.     var gcDiv,glDiv,grDiv,off;
  5.  
  6.     function setVars(){
  7.         gcDiv     = MM_findObj('greenCover');
  8.         glDiv     = MM_findObj('greenleft');
  9.         grDiv    = MM_findObj('greenright');
  10.         off     = gcDiv.offsetLeft;
  11.     }
  12.     function moveToRight(){
  13.         if(glDiv.style.display != 'block'){glDiv.style.display = 'block';};
  14.         if(off < 1000){
  15.             off = off + 5; gcDiv.style.left = off + "px";
  16.         }else{gcDiv.style.display = "none"; win.clearInterval(moveID);}
  17.         //document.getElementById("output").innerHTML = gcDiv.style.left;
  18.     }
  19.     function int_moveToRight(){
  20.         moveID = win.setInterval(moveToRight, 10);
  21.     }
Code tags please - MODERATOR
Jun 25 '07 #1
Share this Question
Share on Google+
4 Replies


acoder
Expert Mod 15k+
P: 16,027
Welcome to TSDN!

Can you give more code, e.g. the HTML/CSS. Alternatively, give a link to a test page.
Jun 26 '07 #2

shoonya
100+
P: 161
i can't any recursion / loop sort of thing which will make your page move
(may be i am missing some thing)

but when the div reaches the given position, just make it's
Expand|Select|Wrap|Line Numbers
  1. document.getElementById('div_id').style.display="none"
  2.  
i think it should work fine

shoonya
Jun 26 '07 #3

P: 17
Never mind this post.

This is a messed up way of doing the same effect that I could do with all flash. Plus, every browser I've tested it in, it's differant or it dosn't work at all.

-J
Jun 27 '07 #4

shoonya
100+
P: 161
it's bit messy
but it has got it's own advantage,
you don't need any extra falsh plug-in to display this thing :D

shoonya
Jun 28 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.