我正在尝试为我的代码创建一个掷骰子按钮,但我不太确定如何做到这一点,因为如果我创建了一个,要么它也无法按我想要的方式工作,要么我的按钮无法正常工作。<html><head> <link rel="stylesheet" type="text/css" href="style.css" title="Default Styles"/> <script> var r_text = new Array (); r_text[0] = "All leave are brown"; r_text[1] = "fafwfaf"; r_text[2] = "fakfjwkfkajwkfawjf"; r_text[3] = "cornflakes"; r_text[4] = "bannana"; r_text[5] = "Choclate"; r_text[6] = "lol"; var i = Math.floor(7*Math.random()) var videos = [ { id: 1, url: "https://www.youtube.com/embed/ngUMyF9D9SQ?autoplay=1", text: r_text[i] }, { id: 2, url: "https://www.youtube.com/embed/v=r-l_gVPVylM?autoplay=1", text: r_text[i] }, { id: 3, url: "https://www.youtube.com/embed/6ukTzRjXcR0?autoplay=1", text: r_text[i] }, { id: 4, url: "https://www.youtube.com/embed/n5BXMNCTu8I?autoplay=1", text: r_text[i] }, { id: 5, url: "https://www.youtube.com/embed/JtwVmnMNaEY?autoplay=1", text: r_text[i] }, { id: 6, url: "https://www.youtube.com/embed/lAMgRaHP8Q4?autoplay=1", text: r_text[i] }];window.onload = function() { var playerDiv = document.getElementById("random_player"); var player = document.createElement("IFRAME"); var previousId = localStorage.getItem("previousId"); if (previousId) { var previousIndex = videos.findIndex(v => v.id === parseInt(previousId)); videos.splice(previousIndex, 1); }我希望它一开始除了按钮之外什么都没有,一旦点击按钮,视频就会开始播放,然后其他一切都开始发生。
添加回答
举报
0/150
提交
取消