Display Random Image With link on Page Load Using Javascript

With Below Script you can display random image with link on page load using Javascript Code.



<html>
    <head>
        <title>Untitled Document</title>
    </head>
    

    <body>
        <script language="JavaScript">
        <!--
        /*
        Random Image Link Script
        By Website Abstraction (http://www.wsabstract.com)
        and Java-scripts.net (http://www.java-scripts.net)
        */
        
        function random_imglink(){
          var myimages=new Array()
          //specify random images below. You can have as many as you wish
          myimages[1]="img1.gif"
          myimages[2]="img2.gif"
          myimages[3]="img3.gif"
            
          //specify corresponding links below
          var imagelinks=new Array()
          imagelinks[1]="https://github.com/vijayrami"
          imagelinks[2]="https://stackoverflow.com/users/4156460/vijay-rami"
          imagelinks[3]="https://in.linkedin.com/in/vijay-rami-039349109"
        
          var ry=Math.floor(Math.random()*myimages.length)
        
          if (ry==0)
             ry=1
             document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=0></a>')
        }
        
          random_imglink()
        //-->
        </script>
    </body>
</html>

Upload Below Images:



Post a Comment

0 Comments