Return to Snippet

Revision: 827
at August 11, 2006 19:37 by Jaymoon


Initial Code
<!-- Javascript code begins -->

var randomlinks=new Array()

randomlinks[0]='<img alt="" src="images/image-01.gif" width="150" height="75">'
randomlinks[1]='<img alt="" src="images/image-02.gif" width="150" height="75">'
randomlinks[2]='<img alt="" src="images/image-03.gif" width="150" height="75">'

function randomlink(){
var add = randomlinks[Math.floor(Math.random()*randomlinks.length)]
return(add)
}

document.write( randomlink() );

<!-- Javascript code ends -->



<!-- HTML code to use script -->

<script type="text/javascript" src="path/to/script.js"></script>

Initial URL

                                

Initial Description
The ideal use of this code would be to save the Javascript code as a .js file.  Then use the HTML code at the bottom to call it wherever you want on the web page.

Initial Title
Random image with link

Initial Tags
javascript, image, link, html

Initial Language
JavaScript