Sao Ho
Sao Ho

Reputation: 139

JavaScript keydown not working on Firefox

$("body").keydown(function(e) {
    if (e.which == 116) {
        window.location.href = "google.com";
    }
});

I used this code so that every-time someone press f5 it will force them to go to other URL. I tested this with Chrome and it worked fine but with FireFox, nothing happens.

Please help me with this.

Thank you!

Upvotes: 0

Views: 268

Answers (1)

pixellab
pixellab

Reputation: 608

this is working fine

$(function() {
  $("body").keydown(function(e) {
    e.preventDefault();
    if (e.which == 116) {
      window.location.href = "http://google.com";
    }
  });
});

Upvotes: 1

Related Questions