dcsimg

Assignment 47: A Possible Answer

This...

<script language="JavaScript">
var newurls=new Array()
newurls[0]="http://www.cnn.com"
newurls[1]="http://www.ibm.com"
newurls[2]="http://www.digital.com"
newurls[3]="http://www.disney.com"

function picksite()
{
now=new Date()
num=(now.getSeconds())%4
location.href = newurls[num]
}
</script>
<center>
<h2>A Random URL</h2>

<form>
<input type="button" value="Click to go to a Random Site" onClick="picksite()">
</form>
</center>

 

Gives you this...

A Random URL

     The effect can be done by offering links as array items. Then the script is run as a function when the button is clicked. You could have also written it so that the button was literally built through the script.

 

Did You Get It?

 

Back to the Index Page