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

regex - check if a string contains only alphabets c#

How to validate that input string contains only alphabets, validating that textbox contains only alphabets (letter), so here is some of the ways for doing such task. char have a property named isLetter which is for checking if character is a letter or not, or you can check by the regular expression  or you can validate your textbox through regular expression validator in asp.net. Following code demonstrating the various ways of implementation.

Regular expression for alphanumeric with space in asp.net c#

How to validate that string contains only alphanumeric value with some spacial character and with whitespace and how to validate that user can only input alphanumeric with given special character or space in a textbox (like name fields or remarks fields). In remarks fields we don't want that user can enter anything, user can only able to enter alphanumeric with white space and some spacial character like -,. etc if you allow. Some of regular expression given below for validating alphanumeric value only, alphanumeric with whitspace only and alphanumeric with whitespace and some special characters.

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 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-".

Uploading large file in chunks in Asp.net Mvc c# from Javascript ajax

Often we have a requirement to upload files in Asp.net, Mvc c# application but when it comes to uploading larger file, we always think how to do it as uploading large file in one go have many challenges like UI responsiveness, If network fluctuate for a moment in between then uploading task get breaks and user have to upload it again etc.