/    Sign up×
Community /Pin to ProfileBookmark

Javascript Event Question

Hi,

I have an internal, IE only web app and I need to capture certain key combinations and cancel the events. Here is a sample page:

<html>
<head>
<title>Test Page</title>
</head>
<body>
<script language=”JavaScript”>
function KeyDown(){
exitValue = true;
//capture [alt]+[home]
if(event.keyCode == 36 && event.altKey) {
// alert(“got it”)
document.all[‘messageArea’].innerHTML = “Got it!”;
event.keyCode=0
event.returnValue=false
exitValue=false
}
return exitValue
}
document.onkeydown=KeyDown
</script>

<div id=”messageArea”>Loaded … </div>
</body>
</html>

If you look at the part where the alert is, you’ll see that it’s commented out. With it commented out, all of the code runs and then you still get sent to the home page (alt + home). However, when the alert is called, the code runs and you are NOT sent to the home page.

Finally, the question:

What is happening to the event when an alert is called? Is there another way to cancel the event without opening a new window or an alert box?

Thanks in advance!

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@DThomasauthorSep 23.2004 — Any ideas?
×

Success!

Help @DThomas spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...