开发者

Go back to previous page after a delay

I want to go to the previous page after a 2 second开发者_如何学运维 delay using jQuery. I thought maybe I could do it this way but I think 'm using this in the wrong context. Code doesn't do anything worthwhile.

function goBack() {
    $(this).delay(3000, function(){
      history.back();}
    return false;
    }


The second argument to delay() is a queueName, not a function to run after the delay. Use setTimeout instead:

setTimeout(function(){history.back();}, 3000);


JS Code

setTimeout('history.go(-1)', 3000);


<button type="button" onclick="history.back();">Back</button>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜