0
버튼을 누르면 임의의 웹 페이지 (나는 35 개가 있음)를 선택하는 웹 사이트를 만들려고합니다. 그러나 나는 한 번만 각 사이트에 가고 싶습니다. 나는 쿠키가 그 일을 할 수 있다고 생각하지만 어떻게해야하는지 확신 할 수 없다. 그래서 어떤 페이지를 방문했는지, 어떤 페이지를 방문했는지 기억하지 못하도록 쿠키를 저장하려고합니다. JavaScript에 익숙하지 않으므로 잘 보내주십시오.어떤 웹 페이지를 방문했는지 기억하고 있습니다.
내 자바 스크립트 : 내 웹 페이지의
function myFunction() {
var tal=Math.floor((Math.random() * 35) + 1)
window.location.href = "Sang"+tal+".html";
}
하나 :
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Gæt en sang</title>
<link rel="stylesheet" type="text/css" href="main.css">
<script src="Test.js"></script>
</head>
<body>
<audio class="hidden" controls autoplay>
<source src="horse.ogg" type="audio/ogg">
<source src="pokemon.mp3" type="audio/mpeg">
</audio>
<div id="header">
<h2> Gæt sangen og hejs flagstangen!</h2>
</div>
<div id="left">
<ul> Hvilken sang er dette?
</br>
<button type="button" onclick="myFunction()">
<li> World we must defend </li>
</button>
</br>
<button type="button" onclick="myFunction()">
<li> Pokemon theme</li>
</button>
</br>
<button type="button" onclick="myFunction()">
<li> Gotta Catch 'em All<li>
</button>
</br>
<button type="button" onclick="myFunction()">
<li> You teach me i teach you <li>
</button>
</ul>
</div>
</div>
<p id="Test"></p>
</body>
</html>