Explore the strange effects of setInterval Switching tags in Firefox and chrome, and solutions!

Source: Internet
Author: User

In the previous article: I felt that the text in the lower-left corner of pig 8 had a good effect. I tried it myself and implemented it in my own way!

This is the case, but it has little impact. The Demo has a big impact!

Some people have encountered such problems on the Internet. refer to the following post address:

SetInterval in firefox 6

There are many people to discuss, but no answer is provided.

I don't even understand what I think!

Today, suddenly, it may be the concept of a thread, but the specific reason is still not clear. I hope someone can understand what it was supposed to say. Thank you very much!

The black Div in the Demo is not affected by browser tag switching.

The red Div will be affected.
HTML:
Copy codeThe Code is as follows:
<Div id = "move" style = "position: absolute; width: 100px; height: 100px; top: 0pt; left: 0pt; background: none repeat scroll 0% 0% #000000; z-index: 999; color: # ffffff; "> I am not affected by browser tag switching! Hoooo </div>
<Div id = "move2" style = "position: absolute; width: 100px; height: 100px; top: 0pt; left: 0pt; background: none repeat scroll 0% 0% red; z-index: 999; color: # ffffff; "> I'm affected by browser tag switching! 5555 </div>

Javascript:
Copy codeThe Code is as follows:
(Function (){
Var elem = Meng. getId ('move '),
Elem2 = Meng. getId ('move2 '),
Pos = Meng. getElemViewPosition (elem ),
View = Meng. getBrowserView (),
// Gray block motion function
Move = function (){
Var t1 = Meng. animate (elem, {top: 0, left: 0}, {top: view. height-100, left: view. width-100}, 3000, function (){
Var t2 = Meng. animate (elem, {left: view. width-100}, {left: 100-view.width}, 3000, function (){
Var t3 = Meng. animate (elem, {top: view. height-100}, {top: 100-view.height}, 3000, function (){
Move (); // after determining the t3 motion, I will call back the move () function.
});
});
});
};
Move ();
// Red block motion function
Meng. setStyle (elem2, {top: 0, left :( view. width-100) + 'px '});
Var move2 = function (){
Var t1 = Meng. animate (elem2, {top: 0, left: view. width-100}, {top: view. height-100, left: 100-view.width}, 3000, function (){
Var t2 = Meng. animate (elem2, {top: view. height-100}, {top: 100-view.height}, 3000, function (){
Var t3 = Meng. animate (elem2, {left: 0}, {left: view. width-100}, 3000, function (){
});
});
});
};
Move2 ();
SetInterval (function () {move2 () ;}, 9050 );
// Red block motion function
})();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.