JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old November 17th, 2005, 10:32 AM
skelterweb skelterweb is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2005
Posts: 13 skelterweb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 50 m 45 sec
Reputation Power: 0
Disable F5 key

i need to disable the F5 key, i searched and i found some things but not clear for me, it should works in Firefox.

i found this:

function blockA(e) {
var keyChar = String.fromCharCode(e.which);
if (keyChar == 'A' || keyChar == 'a')
//self.scrollBy(10,10);

else if(keyChar == 'Z' || keyChar == 'z')
self.scrollBy(-10,-10);

else return false;
}
document.captureEvents(Event.KEYPRESS);
document.onkeypress = blockA;

but i cant make it work for F5 (keycode=116)

can anyone help me with this one?
thanks

Reply With Quote
  #2  
Old November 21st, 2005, 03:25 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 956 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 651197 Folding Title: Super Ultimate Folder - Level 2Folding Points: 651197 Folding Title: Super Ultimate Folder - Level 2Folding Points: 651197 Folding Title: Super Ultimate Folder - Level 2Folding Points: 651197 Folding Title: Super Ultimate Folder - Level 2Folding Points: 651197 Folding Title: Super Ultimate Folder - Level 2Folding Points: 651197 Folding Title: Super Ultimate Folder - Level 2Folding Points: 651197 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 8 h 23 m 32 sec
Reputation Power: 4
Send a message via ICQ to Itsacon
Well you can try stuff like this by setting an onKeyPress handler on every object likely to receive focus, but remember two things:
  • This is not reliable, it is very easy to circumvent, and chances are it'll behave differenly across different browsers.
  • You'll only piss off your visitors. It is not up to you to decide what a user can and can't do with his browser. If you want full control, write an application, not a website.
Comments on this post
MadCowDzz agrees: "If you want full control, write an application, not a website." -- Couldn't have said it better
myself!
Icon agrees: Abusing javascript to change browser behaviour like this is evil
__________________
This is my code. Is it not nifty?

"The biggest problem encountered while trying to design a system that was completely foolproof, was, that people tended to underestimate the ingenuity of complete fools."
---Douglas Adams


Join the Itsacon fanclub!    
Zero Tolerance: Spammers banned so far: 264

Reply With Quote
  #3  
Old November 22nd, 2005, 05:56 AM
skelterweb skelterweb is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2005
Posts: 13 skelterweb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 50 m 45 sec
Reputation Power: 0
its for an application, not for a website....

Reply With Quote
  #4  
Old November 22nd, 2005, 09:03 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 956 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 651197 Folding Title: Super Ultimate Folder - Level 2Folding Points: 651197 Folding Title: Super Ultimate Folder - Level 2Folding Points: 651197 Folding Title: Super Ultimate Folder - Level 2Folding Points: 651197 Folding Title: Super Ultimate Folder - Level 2Folding Points: 651197 Folding Title: Super Ultimate Folder - Level 2Folding Points: 651197 Folding Title: Super Ultimate Folder - Level 2Folding Points: 651197 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 8 h 23 m 32 sec
Reputation Power: 4
Send a message via ICQ to Itsacon
If you open it in a browser, it's a website in my book...

Reply With Quote
  #5  
Old November 22nd, 2005, 10:45 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
The word application has evolved. Now one must make a distrinction between desktop application and web application.

From an enterprise perspective, many applications are becoming web based... it allows for a wider user-base, and universal access to the web-application. I can see where skelterweb may be coming from.

However, from a technical perspective, I'm unaware of any way to disable the F5 key using web-code. Don't forget about Ctrl+R, or Ctrl+F5, or any other variations that any web-browser may have.

I think it may be better to just suck-in the fact that the user can refresh the page and perhaps workout someway so your web application doesn't blow-up when that happens.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Disable F5 key


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway