Inconsistency with window.history.back()

前端 未结 2 682
梦如初夏
梦如初夏 2021-01-13 23:02

I have the following code in an MVC view that I\'m using to test window.history.back()

\"enter

相关标签:
2条回答
  • 2021-01-13 23:39
    $('#cancelButton').click(function(e){
        e.preventDefault();
    
        /* ... code ... */
    });
    
    0 讨论(0)
  • 2021-01-13 23:41

    The browser is probably interpreting the button as a submit button and submitting the form, thus causing a page refresh. Adding type="button" will prevent that.

    <button type="button">Cancel</button>
    
    0 讨论(0)
提交回复
热议问题