dkilby
asked on
OnKeyPress - spacebar
I want to be able to close the current window that has automatically been opened when the space bar is presse. Is this possible and if so how?
Thanks
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
what do you mean by current window.
if you want to close window use:
window.close();
if you want to capture space bar event use:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<script>
function catchSpaceBar(event){
if(navigator.appName.index Of('Netsca pe') != -1 ){
if (event.keyCode == 32){
alert('Space was captured');
window.close();
}
}
else{
if (window.event.keyCode == 32) {
alert('Space was captured');
window.close();
}
}
}
document.onkeyup = catchSpaceBar;
</script>
!!! important:
For newer Netscape browsers,
their on-line manual says:
"To unconditionally close a window,
you need the UniversalBrowserWrite privilege."
(which really means a signed script).
</body>
</html>
Nushi.
if you want to close window use:
window.close();
if you want to capture space bar event use:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<script>
function catchSpaceBar(event){
if(navigator.appName.index
if (event.keyCode == 32){
alert('Space was captured');
window.close();
}
}
else{
if (window.event.keyCode == 32) {
alert('Space was captured');
window.close();
}
}
}
document.onkeyup = catchSpaceBar;
</script>
!!! important:
For newer Netscape browsers,
their on-line manual says:
"To unconditionally close a window,
you need the UniversalBrowserWrite privilege."
(which really means a signed script).
</body>
</html>
Nushi.
function kk() {
if(event.keyCode==32) {
//Close Window here
}
}
document.onkeydown=kk
</Script>