javascript - location.replace() 并在返回数据时移动到新页面

标签 javascript jquery html

$.post() 返回一些数据后,我需要移至另一个页面?

验证学生.html:

$.post('students/verify.php',
    function(results){
        preventdefault();
        location.replace("verifystudent.html");
        window.location.href = "completed/student_result.html;
    }

基本上,当verifystudent.html收到数据时,它应该移动到student_result.html,当单击浏览器后退按钮时,它应该避免转到 >verifystudent.html。我怎样才能做到这一点?

最佳答案

尝试这个脚本,它会阻止浏览器的后退按钮,因此在 verifystudent.html 中使用它

<script type = "text/javascript" >
    history.pushState(null, null, 'pagename');
    window.addEventListener('popstate', function(event) {
         history.pushState(null, null, 'pagename');
    });
</script>

希望这有帮助。

关于javascript - location.replace() 并在返回数据时移动到新页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33824455/

相关文章:

javascript - 如何添加到 HTML 附件,例如 href =""

javascript - Guard 执行所有规范导致 Capybara + JS 测试返回 : 'Rack application timed out during boot'

javascript - jQuery Mobile -> 页面生命周期?

javascript - JQuery UI 可排序 : Save keys with sort order

javascript - 如何将文本正文拆分为句子和/或段落分隔符?

html - overflow-x 拒绝显示?

php - Jquery:向上滑动div(如果最后)

javascript - 如何使用 javascript 或 angularjs 从 html 标签中提取/编辑属性?

javascript - 在 Node.js、Socket.io 数组中,socket.id 返回为未定义

javascript - 如何在 SPAN 旁边的 DIV 中获取文本