Thursday, 18 October 2012

Show random images on page refresh using Java Script in asp.net

Try this javaScript to change image background on page refresh/page reload...........


<script type="text/javascript">
      function banner() { } ; b = new banner() ; n = 0
 b[n++]= "<img name=randimg src='icon/p1.jpg' width=100% height=395>"
 b[n++]= "<img name=randimg src='icon/p2.jpg' width=100% height=395>"
 b[n++]= "<img name=randimg src='icon/p3.jpg' width=100% height=395>"
 i=Math.floor(Math.random() * n) ;
 document.write( b[i] )
     </script>

No comments:

Post a Comment