Reputation: 139
following code works perfectly on FF and Chrome but not in IE8.
$(window).keyup(function(e) {
var code = e.which
if (code == 9)
{
alert("do stuff");
cellContent();
autoDate();
}
});
This code will recognize the tab and does the function cellContent() and autoDate(). I added alert to see if this functions are ever used on IE8 but it doesnt seem like it recognizes it.
Thanks in advance!
Upvotes: 2
Views: 1606
Reputation: 139
I have found the answer! All I had to do was instead of doing
$(window).keyup(function(e) {
var code = e.which
if (code == 9)
{
alert("do stuff");
cellContent();
autoDate();
}
});
I just had to do change $(window) to $(document)
$(document).keyup(function(e)
{
var code = (e.keyCode ? e.keyCode : e.which);
if (code == 9)
{
alert("hello world");
cellContent();
autoDate();
}
});
Thank you for all the help
Upvotes: 2
Reputation: 47966
Why don't you try using this statement to decide what value to use. It seems to work for me on all the major browsers.
var code = (e.keyCode ? e.keyCode : e.which);
I'm not entirely sure of the technical explanation, but a quick search gave me this page :
http://unixpapa.com/js/key.html
It contains a table with references to each major browser and which property they support
Continuation from comments :
Additionally, try binding the event with this syntax :
$(window).bind('keyup', callBack);
Or maybe tried binding the event to document :
$(document).bind('keyup', callBack);
Upvotes: 0