jquery: history.back(1) issue

前端 未结 3 1159
时光取名叫无心
时光取名叫无心 2021-02-13 19:09

I have an issue with jquery and history.back(): I got a link:

Link back

I cant use something like

相关标签:
3条回答
  • 2021-02-13 19:24

    I'd try:

    javascript: history.back(1)
    

    otherwise using:

    javascript: history.go(1)
    

    the browser will stay where it is. That's not really what was initially requested, is it?

    0 讨论(0)
  • 2021-02-13 19:37

    Probably you are missing to specify event as function argument, try specifying that too:

    $("#backLink").click(function(event) {
        event.preventDefault();
        history.back(1);
    });
    

    In other words, you had problem on event.preventDefault(); which most likely prevented below code from running or working.

    0 讨论(0)
  • 2021-02-13 19:40

    An easy method:

     <a href="javascript: history.go(1)" id="backLink">Link back</a>
    
    0 讨论(0)
提交回复
热议问题