2017-03-26 13 views
0

私は各スコア10.クイズ

のうち、スコアを計算するために、同じページ上の動的更新を使用してクイズを作成しようとしていますが、私はプログラムが別のWebページをロードする別のEndscreensに基づいてページを起動します彼らが得点に基づいて、

例えば、スコアがある場合:

1 = Endscreen1.html 
2 = Endscreen2.html 
3 = Endscreen3.html 
4 = Endscreen4.html 
5 = Endscreen5.html 
6 = Endscreen6.html 

私は私が10のスコアに基づいて別のページを起動するために何をする必要があります何を、以下のコードがありますか?

function showScores() { 
var gameOverHtml = "<h1>Result</h1>"; 
gameOverHtml += "<h2 id='score'> Your score, click the score button below to guide patient: " + quiz.score + "</h2>"; 
var element = document.getElementById("quiz"); 
element.innerHTML = gameOverHtml; 
}; 
+0

を呼び出すことができますページ。それはどちらか一方になるはずです。どちらもナンセンスだろう。 –

答えて

0

この機能は、ヘッダータグ内に配置する必要があります。

<html> 
    <head> 

    <script type="text/javascript"> 
    function Redirect() { 
     //get users score and assign it to score variable 
     if(score == 1) 
     { 
      window.location="Endscreen1.html"; 
     } 
     else if (score ==2) 
     { 
      window.location="Endscreen2.html"; 
     } 
     else 
     { 
      window.location="Endscreen6.html"; 
     } 
    } 
    </script> 

    </head> 

    <body> 
    </body> 
</html> 

書かれたコードは `element.innerHTML = gameOverHtml`で既存のページを変更していますが、別のを起動するためのコードを求めているとして、あなたは、関数リダイレクト()showScores内の()関数