2013-03-26 5 views
0
<html> 
<head> 
<title>Practice</title> 

<script LANGUAGE="Javascript" type="text/javascript"> 

function myfunction() { 
var element=document.getElementById("data1"); 
var element2=document.getElementById("bulkcontent"); 
var fname=prompt("Please enter your name:", "Your name"); 
var gend=prompt("Please enter your gender:", "Your gender"); 
var age=prompt("Please enter your age:", "Your age"); 
var pic=prompt("Please provide a picture url:", "Picture Url"); 
var r=confirm("Do you really wish to create a table? If you are unsatisfied with your result, please refresh the page."); 


    if(r==true) 
     { 
element.innerHTML = "<table height='500' width='450' border='3' style='color:green;'><tr><th rowspan='3' height='350' width='250'><img src='" + pic + "' height='350' width='250' alt='UserPic' /></th><td height='150' width='200'><center><u>Name:</u></center><center>" + fname + "</center></td></tr><tr><td height='150' width='200'><center><u>Gender:</u></center><center>" + gend + "</center></td></tr><tr><td height='150' width='200'><center><u>Age:</u></center><center>" + age + "</center></td></tr><tr><td colspan='2'width='450' height='150'><center><u>Inventory</u></center><br/><center>1. --- 2. --- 3. --- 4. ---</center><br/></td></tr></table>"; 

element2.innerHTML = "<table border='3' style='color:green;'<tr><td colspan='2' height='400' width='400'><img src='http://i.imgur.com/b4lrB.jpg' alt='startarea' /></td></tr><tr><td width='60'><input type='button' value='enter' onClick='myfunction2()'></input><input type='button' value='Look Around' onClick='lookaround1()'></input></td><td width='340'><p>You are " + fname + ", and you have stumbled across this abandoned school house on a rainy night. You really don't want to go inside, but it's been miles and a " + gend + ", such as yourself, can't stand to be in the rain. What will you do?</p></td></tr></table>"; 
     } 
    else if(r==false) 
     { 
      alert("Reconsider for a bit and return to us with a more decisive plan of action little wriggler.") 
     } 
} 
function myfunction2() 
{ 
    alert("Welcome Aka, please click the create table button to get started, but first read the paragraph in the table below! KK: DO IT FAST AKA HURRY THE F--K UP! THIS TIME IT IS DIFFERENT. YOU MIGHT ACTUALLY SEE A SLIDE COME UP!") 
} 

function lookaround1() 
{ 

var audio=document.getElementById("audio"); 

setTimeout(lookaround1() 
{audio.play();},3000);} 

</script> 

</head> 
<body style="background-color:black;color:white;" onLoad="myfunction2()"> 

<div id="data1" style="opacity:0.5;width:0px;float:left;position:relative;left:0px;top:25px;"> 


</div> 

<div id="bulkcontent" style="opacity:0.5;width:450px;height:550px;color:white;float:middle;position:relative;right:-460px;top:0px;"> 
<br/> 
<hr/> 
<br/> 
<p>Welcome to the character creation menu, Today we are going to create a character. When you click on the create table button answer the promp questions as they are asked. Afterwards your character table shall be made. Scroll down a bit for the create table button!</p> 
<br/> 
<hr/> 
<br/> 
<center>Coded by Brandyn Porter. hOnK hOnK :o) 2013 </center> 
</div> 
<div id="links" style="opacity:0.7;width:250px;float:right;position:relative;right:85px;top:-475px;"> 
<img src="http://media.tumblr.com/tumblr_ln04c8bSpu1qin2iv.png" height="300" width="250" alt="gamzee" /> 
<hr/> 
<br/> 
<p style="color:white;">This is Gamzee. Gamzee says motherf--king hello, he also motherf--king asks for some motherfucking faygo. Are you gonna motherfucking deny this motherf--ker some motherf--king faygo? Yeah I didn't motherf--king think so.</p> 
<br/> 
<hr/> 
</div> 


<br/> 
<hr width="1300" /> 
<br/> 


<input onClick="myfunction()" style="float:middle;position:relative;right:-635px;top:25px;" type="button" value="Create Table" ></input> 

<audio src="sc1.ogg" height="0" width="0" id="audio"></audio> 

</body> 
</html> 

이 코드는 웹 페이지에 대한 자신 만의 모험 이야기 유형의 게임을 선택하기위한 것입니다. 기본적으로이 페이지는 소개를하기위한 매우 원시적 인 시도이며, 테이블 만들기 버튼을 만들 때 몇 가지 질문과 대답이 표로 표시됩니다. 이제부터는 세 개의 테이블이 제공됩니다. 하나는 문자 데이터 테이블 내부에 제공 한 정보이고, 다른 하나는 그림과 일부 단추와 대화 상자이며, 마지막 하나는 당분간 장식입니다. 이제 입력 버튼에 대한 자리 표시 자 기능이 있지만 사실 "둘러보기"기능을위한 의도 된 기능이 있습니다. 이 버튼을 누르면 3 초 후에 사운드가 재생되고 나면 사운드에 대해 알려주는 경고 메시지가 표시됩니다. setTimeout 함수를 코딩하려고했지만 몇 가지 코드를 입력 할 때마다 스크립트 전체가 중단되고 더 이상 작동하지 않습니다. 나는 자바 스크립트에 상당히 익숙하지 않기 때문에 내가 뭘 잘못하고 있는지 확신 할 수 없다. 다른 세부 사항이 필요한 경우 :(내가 제공하게 행복 할 것이다.setTimeout 함수 내에 코드를 구현할 때의 문제

답변

0
<html> 
<head> 
<title>Practice</title> 
<script type="text/javascript"> 
    function myfunction() { 
     var element = document.getElementById("data1"); 
     var element2 = document.getElementById("bulkcontent"); 
     var fname = prompt("Please enter your name:", "Your name"); 
     var gend = prompt("Please enter your gender:", "Your gender"); 
     var age = prompt("Please enter your age:", "Your age"); 
     var pic = prompt("Please provide a picture url:", "Picture Url"); 
     var r = confirm("Do you really wish to create a table? If you are unsatisfied with your result, please refresh the page."); 

     if (r == true) { 
      element.innerHTML = "<table height='500' width='450' border='3' style='color:green;'><tr><th rowspan='3' height='350' width='250'><img src='" + pic + "' height='350' width='250' alt='UserPic' /></th><td height='150' width='200'><center><u>Name:</u></center><center>" 
        + fname 
        + "</center></td></tr><tr><td height='150' width='200'><center><u>Gender:</u></center><center>" 
        + gend 
        + "</center></td></tr><tr><td height='150' width='200'><center><u>Age:</u></center><center>" 
        + age 
        + "</center></td></tr><tr><td colspan='2'width='450' height='150'><center><u>Inventory</u></center><br/><center>1. --- 2. --- 3. --- 4. ---</center><br/></td></tr></table>"; 

      element2.innerHTML = "<table border='3' style='color:green;'<tr><td colspan='2' height='400' width='400'><img src='http://i.imgur.com/b4lrB.jpg' alt='startarea' /></td></tr><tr><td width='60'><input type='button' value='enter' onClick='myfunction2()'></input><input type='button' value='Look Around' onClick='lookaround1()'></input></td><td width='340'><p>You are " 
        + fname 
        + ", and you have stumbled across this abandoned school house on a rainy night. You really don't want to go inside, but it's been miles and a " 
        + gend 
        + ", such as yourself, can't stand to be in the rain. What will you do?</p></td></tr></table>"; 
     } else if (r == false) { 
      alert("Reconsider for a bit and return to us with a more decisive plan of action little wriggler.") 
     } 
    } 
    function myfunction2() { 
     alert("Welcome Aka, please click the create table button to get started, but first read the paragraph in the table below! KK: DO IT FAST AKA HURRY THE F--K UP! THIS TIME IT IS DIFFERENT. YOU MIGHT ACTUALLY SEE A SLIDE COME UP!") 
    } 

    function lookaround1() { 
     var audio = document.getElementById("audio"); 
     audio.play(); 
     setTimeout(lookaround1, 3000); 
    } 


</script> 

</head> 
<body style="background-color: black; color: white;" 
    onLoad="myfunction2()"> 

    <div id="data1" 
     style="opacity: 0.5; width: 0px; float: left; position: relative; left: 0px; top: 25px;"> 


    </div> 

    <div id="bulkcontent" 
     style="opacity: 0.5; width: 450px; height: 550px; color: white; float: middle; position: relative; right: -460px; top: 0px;"> 
     <br /> 
     <hr /> 
     <br /> 
     <p>Welcome to the character creation menu, Today we are going to 
      create a character. When you click on the create table button answer 
      the promp questions as they are asked. Afterwards your character 
      table shall be made. Scroll down a bit for the create table button!</p> 
     <br /> 
     <hr /> 
     <br /> 
     <center>Coded by Brandyn Porter. hOnK hOnK :o) 2013</center> 
    </div> 
    <div id="links" 
     style="opacity: 0.7; width: 250px; float: right; position: relative; right: 85px; top: -475px;"> 
     <img src="http://media.tumblr.com/tumblr_ln04c8bSpu1qin2iv.png" 
      height="300" width="250" alt="gamzee" /> 
     <hr /> 
     <br /> 
     <p style="color: white;">This is Gamzee. Gamzee says motherf--king 
      hello, he also motherf--king asks for some motherf--king faygo. Are 
      you gonna motherf--king deny this motherf--ker some motherf--king 
      faygo? Yeah I didn't motherf--king think so.</p> 
     <br /> 
     <hr /> 
    </div> 


    <br /> 
    <hr width="1300" /> 
    <br /> 


    <input onClick="myfunction()" 
     style="float: middle; position: relative; right: -635px; top: 25px;" 
     type="button" value="Create Table"></input> 

    <audio src="sc1.ogg" height="0" width="0" id="audio"></audio> 

</body> 
</html> 

내가 잘못의 setTimeout 기능을 사용하는 것 같아요.

https://developer.mozilla.org/en/docs/DOM/window.setTimeout

function lookaround1() { 
    var audio = document.getElementById("audio"); 
    audio.play(); 
    setTimeout(lookaround1, 3000); 
} 
관련 문제