web - How can I have refresh page link/button inside my JavaScript code? -
basically have following code checks user input , gives output accordingly:
<script> function checkuserinput() { var userinput = document.getelementbyid("textinput").value; var stringtocheckagainst = random_images_array[num].split('.'); if (userinput.touppercase() == stringtocheckagainst[0].touppercase()) { document.getelementbyid("row1").innerhtml="<p>" + txt.fontsize(5) + "</p>";document.close(); } else { //user has inputted incorrect string document.getelementbyid("row1").innerhtml="<p>" + txt1.fontsize(5) + "</p>";document.close(); } } </script>
however problem is, in case user response not correct , programme displays “incorrect message”, need show refresh or reset button or text clicking on link user can again refresh page , gets new challenge.
function checkuserinput() { var userinput = document.getelementbyid("textinput").value; var stringtocheckagainst = random_images_array[num].split('.'); if (userinput.touppercase() == stringtocheckagainst[0].touppercase()) { document.getelementbyid("row1").innerhtml="<p>" + txt.fontsize(5) + "</p>";document.close(); } else { //user has inputted incorrect string document.getelementbyid("row1").innerhtml="<p>" + txt1.fontsize(5) + "<a href='#' onclick='javascript:location.reload();'>try again</a></p>";document.close(); } } </script>
Comments
Post a Comment