Random link : Random « Language Basics « JavaScript DHTML






Random link

  

<html>
<body>

<script type="text/javascript">
var r=Math.random()
if (r>0.5){
    document.write("<a href='http://www.java2s.com'>java2s</a>")
}else{
    document.write("<a href='http://www.google.ca'>Google!</a>")
}
</script>

</body>
</html>


           
         
    
  








Related examples in the same category

1.Unique Random Numbers
2.Unique Random Sets
3.Math Random number: a random number between 0 and 1
4.Random number from 0 to 10: a random number from 0 to 10 using the random() and round()
5.A Random Ad Display Page
6.Random URL
7.Find the random number in a range