我想生成一些文本和图片是随机的引用。有人可以验证此代码,因为它不起作用。按提交时没有任何反应。
<html>
<head>
<title>quote generator Javascript</title>
</head>
<body>
<script type="text/javascript">
quote = new Array()
quote[0] = 'img/einstein.jpg';
quote[1] = 'img/einstein.jpg';
quote[2] = 'img/einstein.jpg';
quote[3] = 'img/einstein.jpg';
text = new Array()
text[0] = 'hallo1';
text[1] = 'hallo2';
text[2] = 'hallo3';
text[3] = 'hallo4';
function popup(){
if(['submit']){
document.write('<a href="' + text[Math.floor(Math.random() * text.lenght)]; + '" ><img src="' + quote[Math.floor(Math.random() * quote.lenght)]; '" style="border:0px;" >');
}
}
</script>
<input type="button" value="random quote" id="submit" onclick="popup()">
</body>
</html>