NO, Why?
To tell you the truth I don't even know what you mean with XXX webadmin
:c)
Javier
Main Topics
Browse All TopicsHi all.
Does anybody know a way to disable ALT-F4 key that really works without making any change to the current document or opening a new window, my code works and it disable the key but I have to display an alert and open a new window or it closes the main one. Besides if I push ALT-F4 again while the alert is open it closes the main window too, I would like to do it without making any of this things.
Tahnks in advantage
Javier
P.D.: Here is how I do it.
document.onkeydown=teclas;
function teclas() {
var tecla = window.event.keyCode;
var control = window.event.ctrlKey;
var alt = window.event.altKey;
var tipo=event.srcElement.type
if (alt) {
switch (tecla) {
// Alt-F4
case 115:
window.event.keyCode=86;
window.cancelEvent=true;
event.cancelBubble=true;
event.returnValue=false;
event.cancel=true;
adios();
return false;
break;
}
}
}
function adios() {
// I have to display this alert first
alert("VEGA :: Opcion no Valida")
// And open this window too or it wont work
openCerrar("cerrar.jsp",40
}
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
OK I see.
Well I'm doing an Intranet application that I want it to work as a client server one and I want to disable user from closing the application without pushing the "Exit" button wich make some validations and invlidates the sesion on the server, the way I told you works but I prefer not to show any message to the client, I do control all the keybord keys, and don let anyone to take any part of the information from the window, I don't know if is wrong or not to do this but if you know the way and don't want to show it here you could sent it to my by mail at ramos_j1@tsm.es, I will appreciate it a lot I've been figuring it out for more than a week and my time cost a lot to my user.
:c)
Javier
For that situations is better to maintain page state and evaluate the state in unload event.
Did you test with body attributes:
<body onLoad="initState()" onUnload="checkState()">
In checkState() function you can notify your server side about session termination, for example in a popup window wich ends with self.close().
I know that I can call the fucntion to disble session on the unload of the document but beside that I don't want the user to close the window with ALT-F4 I have a window made out of 8 frames to simulate a client disign window in 7 of the 8 frames I have no code so if the focus is at one of those I' will have to control to many things, actually I have it done and working with that code but it the user pushes ALT-F4 on the alert it closes the main window. Of course the user can press Ctrl-Alt-Del and kill the task but well I don't know if they'll go that far.
I don't mind deleting the question if nobody is going to answer it. But Zvonk, I know what I want to do!!
Thanks anyway for the replays.
Javier
Thanks devic, but that does not work either as I'm trying. besides that I'd like to display no messages at all if you keep ALT key pressed and push twice F4 key it closes the window.
I'm not really sure if it is possible but I think it is or at least I remember I got a page once on the internet that I only coulded close killing the task.
Javier
here another solution with onbeforeunload event:
===============
<html>
<head>
<title>Untitled</title>
<META http-equiv="Content-Type" content="text/html; charset=windows-1251">
</head>
<body onbeforeunload="DoOnBefore
<script>
var skipCancelClose=false
function DoOnBeforeUnload() {
if(!skipCancelClose){
event.returnValue= "Leaving this page will cause you to lose your connection to the Server!";
}
}
function runit()
{
document.getElementById("s
}
setInterval("runit()",100)
document.onmouseover=funct
document.onmouseout=functi
</script>
<a href=http://www.google.com
<br><br><br>
<center><input id=skipCancelCloseValue></
</body>
</html>
Well Thanks Zvonko, I was begining to think that you knew the solution but weren't going to tell me, I've been searching the net for more than a week and my code is the most i've been able to figure out, I know it has to be a way but....
Devic, thanks for you effort either, I like that solution but I don't think I'll be able to implement it, onbeforeunload event is fired anytime you change a page and I have 200 JSP on my application, the message will appear everytime I change from one part of the application to another becose I close all windows and open a new one when the user change from one part of it to another.
Well guys I'll slit the points on between you, I guess is the best thing I can do, but if you get to it please let me know it, OK.
Thanks again for the effort.
Javier
Business Accounts
Answer for Membership
by: ZvonkoPosted on 2004-01-27 at 01:17:34ID: 10207854
Are you a XXX webadmin?