试图点击magic8,但快乐,悲伤和惊讶的图片不会显示在线以下。我做错了什么?我将random.js中的图像保存在同一个文件夹中。如何点击图片以显示图像的功能
<html>
<head>
<script type=text/javascript src="random.js">
</script>
<script>
function magicEight() {
var imgName;
imgName = RandomOneOf(["happy.gif", "sad.gif", "surprised.gif"]);
document.getElementById('outputDiv').value = imgName;
}
</script>
</head>
<body>
<div style="text-align:center">
<h1> Magic 8-ball (Mattel, Inc.) </h1>
<p> Enter a question below, then click on the Magic 8-Ball to recieve its wisdom. </p>
<input type="text" id="questionBox" size=90 value="">
<p>
<input type="image" src="http://balance3e.com/Images/8ball.gif" id="button" onclick="magicEight();">
</p>
<hr>
<div id="outputDiv"></div>
</div>
</body>
</html>
什么是'random.js'?控制台是否记录了任何错误? – Isaac
什么是'RandomOneOf'? – Dekel
请张贴您的所有代码。它会帮助我们回答你的问题。谢谢。欢迎来到Stackoverflow :) – www139