Skip to main content

Moving Image through javascript like flash file in asp.net

This asp.net article used for making slide show from JavaScript. Many time we need to do such task like moving images in html pages or an aspx page then we think about flash to do that task but it is must to install flash plugin in client browser,so we need an alternative solution of flash to move image just like flash, so here is the solution for making image slide solution through javascript, Just Add Your Image In Picture Array And Add Fuction to body onload.


<html>
<head>
   <script type="text/javascript">
       // Set the slideshow speed (in milliseconds)
       var SlideShowSpeed = 2000;
       // Set the duration of crossfade (in seconds)
       var CrossFadeDuration = 2;
       var Picture = new Array(); // don't change thishttp://www.assoc-amazon.com/e/ir?t=widgetsamazon-20&l=btl&camp=213689&creative=392969&o=1&a=B003A9FFKI
      //***Add Your Image Here To Make Slide Show)**
      Picture[1] = 'https://lh6.googleusercontent.com/-yxSVExWlgVU/TnGzagza8CI/AAAAAAAAAFo/7J-TtBIAeIk/h80/images2.jpeg';

       Picture[2] = 'https://lh6.googleusercontent.com/-T1gMExXTH0k/TnGzfOuwv7I/AAAAAAAAAFs/avs2xX0HItY/h80/images.jpeg';

       Picture[3] = 'https://lh4.googleusercontent.com/-ddekiHGKZZ4/TnGzfx37seI/AAAAAAAAAFw/Xrfj6llMBFc/h80/images1.jpeg';

       Picture[4] = 'https://lh3.googleusercontent.com/-12l1Dtt1jyI/TnGzgp4DZ9I/AAAAAAAAAF4/I-BPvCGbb5k/h80/images3.jpeg';

       Picture[5] = 'https://lh6.googleusercontent.com/-PDV1Qb0iVY4/TnGzhJxAIOI/AAAAAAAAAF8/XQ6Lv3cmhz4/h80/images4.jpeg';

       Picture[6] = 'https://lh4.googleusercontent.com/-tMJmD_E0E2w/TnGzhvrkbTI/AAAAAAAAAGA/_p3JslMbGLA/h80/index.jpeg';

       Picture[7] = 'https://lh5.googleusercontent.com/-rHjrWPBlsug/TnGziCXDNLI/AAAAAAAAAGE/gfhzeGX5Epc/h80/index1.jpeg';

       var tss;
       var iss;
       var jss = pickRandom(Picture.length - 1);
       var pss = Picture.length - 1;
       //alert(jss);
       var preLoad = new Array();
       for (iss = 1; iss < pss + 1; iss++) {
           preLoad[iss] = new Image();
           preLoad[iss].src = Picture[iss];
       }
       function runSlideShow() {
           if (document.all) {
               document.images.LogoBox.style.filter = "blendTrans(duration=2)";
               document.images.LogoBox.style.filter = "blendTrans(duration=CrossFadeDuration)";
               document.images.LogoBox.filters.blendTrans.Apply();
           }
           document.images.LogoBox.src = preLoad[jss].src;
           //if (document.getElementById) document.getElementById("CaptionBox").innerHTML= Caption[jss];
           if (document.all) document.images.LogoBox.filters.blendTrans.Play();
           jss = jss + 1;
           if (jss > (pss)) jss = 1;
           tss = setTimeout('runSlideShow()', SlideShowSpeed);
       }
       function pickRandom(range) {
           if (Math.random)
               return (Math.round(Math.random() * range) + 1);
           else {
               return 1;
           }
       }
   </script>
</head>
<body onload="setTimeout('runSlideShow()', 1001);">
   <!-- Client Name of ImageControl must be 'LogoBox'-->
    <img name="LogoBox" border="0" src="design/space.gif" width="140" >
</body>
</html>


// OutPut of the following code is here:-




Popular posts from this blog

how $document.ready() is different from window.onload()

we often use window.onload() in javascript and $document.ready() in jquery and assume that both are same just jquery library wrap up javascript window.onload() and introduce $document.ready() but no there is much difference between them below is the explanation -

Merging multiple PDFs using iTextSharp in asp.net c#

In this article i will show you how to merge multiple pdfs into one using ITextSharp below is the two approach one is to pass your input files path, output file path (will be created if not exist) and another is pass direct input stream, output stream and it will write the merge files into output stream.

How to handle click event of linkbutton inside gridview

Recently I have posted how to sort only current page of gridview , Scrollble gridview with fixed header through javascript , File upload control inside gridview during postback and now i am going to explain how to handle click event of linkbutton or any button type control inside gridview. We can handle click event of any button type control inside gridview by two way first is through event bubbling and second one is directly (in this type of event handling we need to access current girdviewrow container)

How to validate dropdownlist in JavaScript

In this article you will see how to put validation in dropdownlist by javascript, suppose first item value of dropdownlist is 0 and text is "-Select-" just like given below and we have to validate that at least one item is selected excluding default i.e "-Select-".