4 개의 레벨과 홈페이지가있는 게임을 개발 중입니다. 홈 페이지에서 사용자는 라디오 버튼을 선택하여 4 개의 이미지 중 하나를 선택합니다 (이 페이지에는 4 개의 이미지가 있습니다). 이 선택된 이미지는 모든 레벨에 표시되어야합니다 (예 : 프로필 사진). 그러나 사용자가 어느 레벨에서든 패배하면 홈 페이지 (분명히 새 이미지를 선택할 수 있어야 함)로 이동하고 선택한 이미지가 더 이상 표시되지 않습니다.
이 게임은 HTML과 자바 스크립트로만 개발하고 있습니다. HTML과 자바 스크립트로 할 수 있습니까? 아니라면 PHP를 사용하여 구현할 수 있다면 PHP의 매우 기본적인 사항을 알고 있습니다.
<input type="radio" name="profile" value="boy1" style="margin-left:40px;" onclick="location.href = 'firsta.html';">
<img style="margin-left:25px;" src="boy01.png" width="200" height="200" />
<input type="radio" name="profile" value="boy2" style="margin-left:40px;" onclick="location.href = 'firsta.html';">
<img style="margin-left:25px;" src="boy02.png" width="200" height="200" />
<input type="radio" name="profile" value="girl1" style="margin-left:40px;" onclick="location.href = 'firsta.html';">
<img style="margin-left:25px;" src="girl01.png" width="200" height="200" />
<input type="radio" name="profile" value="girl2" style="margin-left:40px;" onclick="location.href = 'firsta.html';">
<img style="margin-left:25px;" src="girl02.png" width="200" height="200" />
선택한 이미지의 파일 이름을 localStorage (또는 쿠키)로 설정 한 다음 사용하고 싶을 때 다시 읽을 수 있습니다.
<input type="radio" name="profile" value="boy1.png" style="margin-left:40px;" onclick="chooseProfile(this.value, 'firsta.html')">
<img style="margin-left:25px;" src="boy01.png" width="200" height="200" />
자바 스크립트에서 :
function chooseProfile(img, page) {
localStorage.profilePic = img;
location.href = page;
}
그런 다음 읽고 싶을 때 :
document.getElementById('profileImage').src = localStorage.profilePic;
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다