以前は機能していましたが、現在は次のようになっています。
window.event is undefined
以前は機能していたこの単純なコードから:
function checkKey() {
if (window.event.keyCode != 9) {
document.actionForm.saveStatus.value = "Not saved";
}
}
window.eventを使用できなくなったのはなぜですか?
以前は機能していましたが、現在は次のようになっています。
window.event is undefined
以前は機能していたこの単純なコードから:
function checkKey() {
if (window.event.keyCode != 9) {
document.actionForm.saveStatus.value = "Not saved";
}
}
window.eventを使用できなくなったのはなぜですか?
window.eventプロプライエタリソフトウェアです。
イベントに関するデータにアクセスする標準的な方法は、イベントハンドラー関数の最初の引数を使用することです。
function checkKey(e) {
var evt = e || window.event,
keyPressed = evt.which || evt.keyCode;
if (keyPressed != 9) {
document.actionForm.saveStatus.value = "Not saved";
}
You can standardize the check like so:
function checkKey(e) {
var evt = e || window.event;
if (evt.keyCode != 9) {
document.actionForm.saveStatus.value = "Not saved";
}
}