0

On my website i have a button which when clicked takes you to one of two random youtube videos. However i would like to change this to a image in stead of a button.I have tried to change it to a INPUT type="image" but this doesn't work. Here is the code i am using.

         <SCRIPT language="JavaScript">
<!--
function get_random()
{
var ranNum= Math.floor(Math.random()*2);
return ranNum;
}

function getaGame()
{
var whichGame=get_random();

var game=new Array(2)
game[0]= "https://www.youtube.com/watch?feature=player_detailpage&v=NcFQF3PZFRk#t=722s";
game[1]= "https://www.youtube.com/watch?v=klBAW4MQffU";
location.href = game[whichGame];

}
//-->
</SCRIPT>   


<FORM name="form1"> 

<center> 

<INPUT type="button"  onClick="getaGame()" > 
</center>     

</FORM>


Thanks for any help
4

1 回答 1

0

可以onclick从任何元素触发事件。这里有一些例子!

于 2013-06-27T22:00:28.530 回答