JavaScript and client side scripting.
Moderator: General Moderators
-
tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
Post
by tecktalkcm0391 »
I now what the key codes are but I can't get it to work I have:
Code: Select all
<body onLoad="javascript:window.resizeTo(275,225);self.resizeTo(275,225);" onkeydown="if ((event.keyCode==8) || (event.keyCode==122) || (event.keyCode==116)) {event.keyCode=0; return event.keyCode; event.returnValue = false; }">
-
pickle
- Briney Mod
- Posts: 6445
- Joined: Mon Jan 19, 2004 6:11 pm
- Location: 53.01N x 112.48W
-
Contact:
Post
by pickle »
What is 'it' that you want to work?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
-
tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
Post
by tecktalkcm0391 »
I don't want users to be able to click F5 (Refresh) F11 (Full Screen in IE) and Backspace (Back) on a page on my website.
-
pickle
- Briney Mod
- Posts: 6445
- Joined: Mon Jan 19, 2004 6:11 pm
- Location: 53.01N x 112.48W
-
Contact:
Post
by pickle »
Then do your if condition, and if any of those keys are pressed, return false.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
-
pickle
- Briney Mod
- Posts: 6445
- Joined: Mon Jan 19, 2004 6:11 pm
- Location: 53.01N x 112.48W
-
Contact:
Post
by pickle »
Not sure then - Google probably knows
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
-
Benjamin
- Site Administrator
- Posts: 6935
- Joined: Sun May 19, 2002 10:24 pm
Post
by Benjamin »
It might not be possible, the browser might act on those keypresses before they ever get to the Javascript keydown event.
-
pickle
- Briney Mod
- Posts: 6445
- Joined: Mon Jan 19, 2004 6:11 pm
- Location: 53.01N x 112.48W
-
Contact:
Post
by pickle »
agtlewis wrote:It might not be possible, the browser might act on those keypresses before they ever get to the Javascript keydown event.
Good point. There are two events: onkeypress() and onkeydown() - I'm not sure which one is fired before the key press is handled.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
-
tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
Post
by tecktalkcm0391 »
I've tried a lot of stuff but I can't see to get it to work yet I have something else on the same page that works for something else....
-
Lightzero
- Forum Newbie
- Posts: 4
- Joined: Mon Jun 19, 2006 7:53 pm
Post
by Lightzero »
I'm using
Code: Select all
<input type='text' onkeydown='event.keyCode=0;return event.keyCode; event.returnValue = false;' value='abc'/>
I want users can't change the contents of this text, but it doesn't work with code above...
I don't want use "disabled=true"...
Thanks for your help
