Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ctrl + w BAD!!!!

Status
Not open for further replies.

sleuth

Programmer
Jan 12, 2001
134
0
0
US
Hi Java people,

How can I keep someone from pressing crtl + w, I don't want it to carry out the command, I can do this with single keys by using the key code but I can't figure out how you prevent a key combination, I'd also do alt + F4 if anyone can help me.

Thanks,

Tony
 

Ok, I've got ctrl + w disabled, now I'm working on disabling alt-F4,

if (event.altKey && keyCode==115){
event.keyCode=0;
return false;
}

Isn't doing the trick, but I can definatly detect if someone is hitting the alt key.

Tony "Chicks Dig Me Because I'm A Developer,

So I don't approach women because I don't have confidence, but because I'm so cool, that I'm just going to wait until they pick up on me.

Pick-up count so far: 0"
 
Ok, I figured away around preventing Alt-F4, since this is just for a login logout system I simple log the user out when they press alt-F4, so no worries.

Good thing actually that the IE devs didn't let you disable alt-F4 with javascript, imagine what banner ads and popup window advertising would be like .... scary.

Tony
 
hi sleuth,
fine i actually thought this forum is actually for ppl to put forward their questions and several other people are expected to answer in case they know it...but only after reading ur message..i found that we have to put a question up in this forum and after a day we should find answer to it and reply to ourselves........Great work maan...

Okie...coming to ur subject...u might have succeeded in preventing users from clicking alt+f4...but plz check whether if pressing alt+f4 two times gets 'em out of ur code restrictions...bcoz i saw somewher.they had done the same thing as u had done..but when i pressed alt+f4 twice i could come out of that....and also you can never prevent users from pressing ctrl+alt+del and close ur program i suppose....

Regards,
srkss
 
I can always hit the little RHS X at the top of the screen to leave any page I dont understand why you wish to disable people coming out of a page.

 
Well, This is a fullscreen window and I actually didn't find a way to disable alt-F4, I found a way around it, When you hit alt-F4 I had it pop up a new window, small one on the top left of the screen, then in that window you get logged out of my system. That's really all I was after, so if the visitor really wants to leave without logging out, it'll log them out anyway, hehe.

Tony
 
Can someone please tell me how he disabled Ctrl-W and some of the other keys? I can't seem to get any of that to work.

The problem that I am having is that we have an application where if the user can use the back-button or the backspace button or even reload then the server will get confusing messages / the state will get screwed up. Consider this as just one example:

use submits a form containing a reply to a message (for like a forum) to the server, the server returns them the page again with the updated message list. If the user tries to reload, then the message will be posted again.

I know that this can be avoided by using a redirect, however there are several other examples in our web app where this sort of behaviour is undesirable. Is there anything that can be done?

Thanks a lot for your help.
 
here's how: you CANNOT. For the exact reason you realized - imagine someone disabling those functions, then opening a fullscreen window that you could never close.

The best you can do to prevent accidental closings is to use onbeforeunload:

<body onbeforeunload=&quot;return 'Are you sure?';&quot;>

======================================

if (!succeed) try();
-jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top