안녕하세요, 텍스트 영역, onkeypress에서 쿠키를 만들고 결과 페이지에 쿠키를 보낼 수 있는지 궁금합니다. 좋아, 나는 사용자가 텍스트 영역에서 B 또는 R을 입력하면 쿠키 또는 그와 비슷한 것을 만들고 결과 페이지로 보냅니다.textarea onkeypress에 쿠키 만들기 및 보내기
Exercise1.html :
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Exercise1</title>
<style>
#first-child {
width: 200px;
height: 200px;
background: white;
margin-top: 150px;
margin-bottom: 50px;
margin-right: 0px;
margin-left: 550px;
-webkit-animation: myfirst 1s;
animation: myfirst 1s;
}
@-webkit-keyframes myfirst {
0% {background: white;}
20% {background: white;}
40% {background: white;}
60% {background: white;}
80% {background: white;}
100% {background: red;}
}
.first-parent {
color: blue;
margin-top: 5px;
margin-bottom: 50px;
margin-left: 600px;
margin-right: 0px;
}
.second-parent {
color: red;
margin-top: 0px;
margin-bottom: 50px;
margin-left: 40px;
margin-right: 0px;
}
p {
margin-left: 640px;
}
textarea {
width: 30px;
height: 30px;
visibility: ;
margin-top: -50px;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
}
</style>
</head>
<body>
<div id='first-child'></div>
<button class="first-parent" onclick="window.location.href='Exercise2.html'">B</button>
<button class="second-parent" onclick="window.location.href='Exercise2.html'">R</button>
<br />
<p>1/2</p>
<form id="form1" action="result.html" method="get">
<textarea id="aboutme" name="Key Pressed: " autofocus></textarea>
<input type="submit" class="bottom" name="submit" id="submit" value="Test" >
</form>
<script>
document.onkeypress = function(b) {
b = b || window.event;
var charCode = b.charCode || b.keyCode,
character = String.fromCharCode(charCode);
console.log(charCode);
window.location.href="Exercise2.html";
};
document.onkeypress = function(r) {
r = r || window.event;
var charCode = r.charCode || r.keyCode,
character = String.fromCharCode(charCode);
console.log(charCode);
window.location.href="Exercise2.html";
};
</script>
</body>
</html>
Result.html :
나는 그것이 의미가 있는지 알고 여부를하지만 난 최선을 다할 것없는이 각 페이지의 전체 코드는<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>Result</title>
</head>
<body>
<h1>This is the Results</h1>
<script>
var queryString = decodeURIComponent(window.location.search);
queryString = queryString.substring(1);
var queries = queryString.split("&");
for (var i = 0; i < queries.length; i++) {
document.write(queries[i] + "<br>");
}
</script>
</body>
</html>
전체 코드를 게시하는 이유가 궁금하신 경우 메모장에 작성하고 있습니다. 당신이 볼 수 있듯이 jQuery와 Javascript에 대한 자세한 설명이나 코드가 필요한 다른 솔루션이 있다면 알고 있습니다.
-Nikki
당신에 의해 무엇을 의미
'그것은 결과 page'에 보내? AJAX 요청? – hindmost
결과 페이지에 쿠키를 보내도록 요청합니다. – Nikki
이 링크와 비슷한 기능 http://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_textarea_form 추가 이름이 없으면 누를 수있는 키가 없습니다. 다른 페이지 – Nikki