Function 页面赢得';单击警报框后不显示

Function 页面赢得';单击警报框后不显示,function,button,alert,innerhtml,Function,Button,Alert,Innerhtml,创建一个用户回答5个问题的游戏。我想在完成游戏后在单独的页面上显示他们的得分 以下是如何设置我的页面: <div data-role="page" id="displayScore"> <div data-role="header"> <h1>How Did You Go?</h1> </div> <div data-role="content"> <p id="displayScore" align="c

创建一个用户回答5个问题的游戏。我想在完成游戏后在单独的页面上显示他们的得分

以下是如何设置我的页面:

<div data-role="page" id="displayScore">
  <div data-role="header">
    <h1>How Did You Go?</h1>
</div>
<div data-role="content">
<p id="displayScore" align="center"></p>
    <input type="button" value="Play Again?" onClick="startGame();"/>
    <input type="button" value="Main Menu" onClick="" />
</div>
<div data-role="footer">
  <h4>AL</h4>
</div>
</div>
</body>
</html>

你怎么去的?

艾尔
这是我的职责:

function score()
{
    ans += "You scored <strong> " + score + " </strong> out of <strong> " + count + "!</strong>";
    document.getElementById('displayScore').innerHTML = displayScore;
}
功能评分()
{
ans+=“你得分”+得分+“”+计数+“!”;
document.getElementById('displayScore')。innerHTML=displayScore;
}

如果要将值传递到另一个页面,则必须在以下方法之间执行其中一种方法

  • 通过查询字符串传递值(使用get方法)
  • 通过post方法传递值
  • 使用Cookie、localStorage或sessionStorage存储值并在另一个页面中检索值
  • 如果你想打开一个新窗口,代码如下

    window.open('http://www.google.com','GoogleWindow', 800, 600);
    
    如果要创建具有动态值的新窗口,则

    <html>
        <body>
    
        <script>
            myWindow=window.open('','','width=200,height=100');
            var displayScore = "your score";
            myWindow.document.write("<p> + displayScore + </p>")
            myWindow.focus();
        </script>
    
        </body>
    </html>
    
    
    myWindow=window.open('','',宽度=200,高度=100');
    var displayScore=“您的分数”;
    myWindow.document.write(“+displayScore+

    ”) myWindow.focus();
    这是直接用score打开新窗口的最佳方式


    如果您有一个result.html页面,那么您可以通过查询字符串传递分数,或者您可以在result.html页面中编写javascript代码来访问任何cookie、localStorage或sessionStorage以获得分数。但请确保您已将分数保存在其中任何一个中。

    如何显示显示他们分数的页面?函数是否正确?触发函数score()的onlick在哪里?您可以看看我的JSFIDLE吗?这是一个警报框,在另一个功能中,你在寻找上面相同的东西吗?