希望你会做得很好。我尝试使用带有JS的按钮重定向到另一个页面但不知道这段代码不起作用。我需要你的帮助,我们将不胜感激。
由于
<button id="logoutB" type="button" name="submit" class="btn pull-right btn-info">Log Out</button>
<script>
DOCUMENT.getElementById("logoutB").onclick = function () {
location.href = "logout.php";
}
</script>
答案 0 :(得分:3)
document
必须小写:
<script>
document.getElementById("logoutB").onclick = function () {
location.href = "logout.php";
}
</script>
答案 1 :(得分:-1)
或者像这样:
<button id="logoutB" type="button" name="submit" class="btn pull-right btn-info">Log Out</button>
<script>
document.getElementById("logoutB").onclick = function () {
window.location.assign("logout.php");
};
</script>