我有一些我正在查看的Javascript,js代码说:
function buttonClicked(buttonid) {
console.log("entered case statement");
var UrlString = "templates/story/pt1/Start.html";
switch(buttonid) {
case "YesStart":
UrlString = "templates/story/pt1/YesStart.html";
loadDoc(UrlString);
break;
case "NoStart":
UrlString = "templates/story/pt1/NoStart.html";
loadDoc(UrlString);
break;
case "ContinueStart":
UrlString = "templates/story/pt1/ContinueStart.html";
loadDoc(UrlString);
break;
default:
document.getElementById("storybox").innerHTML = "<p>We didn't get to that part yet. Click if you want to</p><button type='button' class='btn btn-danger' id='nobtn' onclick='buttonClicked('YesStart')'>Restart</button>";
<!-- Output error info -->
console.log(buttonid);
};
但是,当我点击我的按钮时,它永远不会重新开始,而且在我按下按钮之前我不会回到开头的位置。有人可以帮我按下按钮吗?
index.html
中最相关的HTML:
<!-- MVC starts here-->
<div class="storybox" id="storybox">
<script src="js/story.js"></script>
</div>
<!-- MVC ends here -->
<!-- Libraries -->
<script src="./js/vendor/jquery-1.11.3.min.js"></script>
<script src="./js/vendor/jquery-ui.min.js"></script>
<script src="./js/vendor/bootstrap.min.js"></script>
<!-- Modules -->
<script type='text/javascript' src="js/story.js"></script>
<div>
<p id="copyright-note">Copyright © Sassafras Associated Ltd 2016. We will shortly be accepting Dogecoin donations ready for phase two.</p>
</div>
模板YesStart.html
是:
<p>[Some text]</p>
<p>[Some more text]</p>
<button type='button' class='btn btn-success' id='continuebtn' onclick='buttonClicked("ContinueStart")'>Continue</button>