) A good image rotation effect

Source: Internet
Author: User

This is an image special effect that is often used in web design. It achieves rotation between multiple images and is connected separately.CodeIt can only be applied to IE. It has never been well solved under ff. We can see this effect on the Baidu Alliance homepage. FF is supported and it can be added to favorites for backup.

 

Java code
  1. <SCRIPT>
  2. VaR links =NewArray ();
  3. Links [1] =Http://tongji.baidu.com";
  4. Links [2] =Http://hi.baidu.com/bdadd/blog/item/6f9f80b12e50cf57092302e3.html";
  5. Links [3] =Http://union.baidu.com/promo/dataunion/index.html";
  6. Links [4] =Http://www.umaz.cn";
  7. VaR IMGs =NewArray ();
  8. For(VAR n =1; N <=5; N ++) IMGs [N] =NewImage ();
  9. IMGs [1]. Src =Http://union.baidu.com/img/tongji550.gif";
  10. IMGs [2]. Src =Http://union.baidu.com/img/banner071031.jpg";
  11. IMGs [3]. Src =Http://union.baidu.com/img/dataunion0711.jpg";
  12. IMGs [4]. Src =Http://union.baidu.com/img/umaz13_550.jpg";
  13. VaR tits =NewArray ();
  14. Tits [1] ="Baidu Statistics";
  15. Tits [2] ="Alliance cup photographers Competition";
  16. Tits [3] ="Baidu Industry Report";
  17. Tits [4] ="Alliance logs";
  18. VaR imgwidth =550;// Image Width
  19. VaR imgheight =134;// Image Width
  20. VaR STR ="<Style type = 'text/CSS '>";
  21. STR + ="# Imgnv {display: none; position: absolute; bottom:-1px; Right: 0; Height: 16px ;}# imgnv Div {float: Left; margin-right: 1px ;}";
  22. STR + ="# Imgnv Div. On, # imgnv Div. off {margin-bottom: 1px; width: 30px; Height: 15px; line-Height: 18px! Important; line-Height: 15px; font-size: 9px; text-align: center; cursor: pointer; cursor: hand }";
  23. STR + ="# Imgnv Div. On {Background: # ce0609; color: # FFF; font-weight: bold }";
  24. STR + ="# Imgnv Div. off {Background: #323232; color: # FFF; text-Decoration: None }";
  25. STR + ="# Titnv {margin-top: 3px; color: #000; text-align: center; display: none ;}";
  26. STR + ="</Style>";
  27. STR + ="<Div style = 'position: relative '>";
  28. STR + ="<Div> <a id = 'dlink' href = '"+ Links [1] +"'Target = '_ blank'> + IMGs [1]. SRC +"'Border = '0' width = '"+ Imgwidth +"'Height = '"+ Imgheight +"'Style = 'filter: alpha (opacity = 100) 'onmouseover = 'pause (true)' onmouseout = 'pause (false) '> </a> </div>";
  29. // Modify point 1: add the inner Div content cyclically to Increase the number
  30. STR + ="<Div id = 'imgnv'> <Div id = 'it1' class = 'on' onmouseover = 'imgswitch (1, true) 'onmouseout = 'pause (false) '> 1 </div> <Div id = 'it2' class = 'off' onmouseover = 'imgswitch (2, true)' onmouseout = 'pause (false) '> 2 </div> <Div id = 'it3' class = 'on' onmouseover = 'imgswitch (3, true)' onmouseout = 'pause (false) '> 3 </div> <Div id = 'it4' class = 'off' onmouseover = 'imgswitch (4, true)' onmouseout = 'pause (false) '> 4 </div>";
  31. STR + ="<Div id = 'titnv'> <B>"+ Tits [1] +"</B> </div>";
  32. STR + ="</Div>";
  33. Document. Write (STR );
  34. VaR OI = Document. getelementbyid ("Dimg");
  35. VaR pause =False;
  36. VaR curid =1;
  37. VaR lastid =1;
  38. VaR Sw =1;
  39. VaR opacity =100;
  40. VaR speed =15;
  41. VaR delay = (document. All )?400:700;
  42. Function setalpha (){
  43. If(Document. All ){
  44. If(OI. filters & Oi. Filters. Alpha) Oi. Filters. Alpha. Opacity = opacity;
  45. }Else{
  46. Oi. style. Required opacity = (opacity> =100)?99: Opacity )/100;
  47. }
  48. }
  49. Function imgswitch (ID, p ){
  50. If(P ){
  51. Pause =True;
  52. Opacity =100;
  53. Setalpha ();
  54. }
  55. Oi. src = IMGs [ID]. SRC;
  56. Document. getelementbyid ("Dlink"). Href = Links [ID];
  57. Document. getelementbyid ("It"+ Lastid). classname ="Off";
  58. Document. getelementbyid ("It"+ Id). classname ="On";
  59. Document. getelementbyid ("Titnv"). Innerhtml ="<B>"+ Tits [ID] +"</B>";
  60. Curid = lastid = ID;
  61. }
  62. Function scrollimg (){
  63. If(Pause & opacity> =100)Return;
  64. If(SW =0){
  65. Opacity + =2;
  66. If(Opacity> delay) {opacity =100; Sw =1;}
  67. }
  68. If(SW =1){
  69. Opacity-=3;
  70. If(Opacity <10) {Opacity =10; Sw =3;}
  71. }
  72. Setalpha ();
  73. If(SW! =3)Return;
  74. Sw =0;
  75. Curid ++;
  76. // Modify point 2: Here, 4 is also the number
  77. If(Curid>4) Curid =1;
  78. Imgswitch (curid,False);
  79. }
  80. Function pause (s ){
  81. Pause = s;
  82. }
  83. Function startscroll (){
  84. Setinterval (scrollimg, speed );
  85. }
  86. Function checkload (){
  87. If(IMGs [1]. Complete =True& IMGs [2]. Complete =True){
  88. Clearinterval (checkid );
  89. SetTimeout (startscroll,2000);
  90. }
  91. }
  92. VaR checkid = setinterval (checkload,10);
  93. </SCRIPT>

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.