Is there a way to detect if the user has pressed the refresh button using jquery or javascript?

前端 未结 5 2035
[愿得一人]
[愿得一人] 2021-01-22 12:48

I want to know if jquery or javascript can detect if the user has pressed the refresh button of their browser? If so can I see an example?

5条回答
  •  悲哀的现实
    2021-01-22 13:15

    Well if you are looking to detect if user press F5 or ctrl+ f5 then you can use following code :)

    $("body").keydown(function (e)
    {
       if (e.which == 116 || e.which == 17) {
         inFormOrLink = true;
       }
    });
    

提交回复
热议问题