HTMLページに実装しようとしているjavacriptがあります。コードは以下の通りです.htmlファイルを開くとすぐに実行するにはどうしたらいいですか?それは私がそれを開くとすぐに体重を入力するように促したい。JavaScript:ページ上で実行されていない
<script type="text/javascript">
var weight = parseInt(prompt("What is your weight?"));
if (weight > 126) {
alert('Please enter a weight lighter than 126');
}
document.writeln('<br/>');
var wArray = ["fly", "superfly", "bantam", "superbantam", "feather"];
function recruit() {
if (0 < weight < 112){
document.writeln('You are in' + wArray[0] +'class!');
}
if (112 < weight < 115){
alert('You are in' + wArray[1] +'class!');
}
if (weight > 115 && weight < 118){
alert('You are in' + wArray[2] +'class!');
}
if(weight > 118 && weight < 122){
alert('You are in' + wArray[3] +'class!');
}
if (weight > 122&& weight < 126){
alert('Your weight class is' + wArray[4]);
}
</script>
ただ、 'parseInt'に'、10'を追加してください。このように: 'parseInt(プロンプト("あなたの体重は何ですか? ")、10)'。 –