I came across a very interesting problem recently. Basicly I am building an editor and I want to take advantage of hot keys. I got it working perfectly in Internet Explorer, But I hit problems when I tried in Firefox, stranger still I found Chrome worked fine.
The problem is the use of hotkeys that are already used in firefox. In my example I have used Ctrl-S (Save page in both FF and Ch). Now I would think evt.preventDefault(); would be the answer, unfortunately this does not work in ff (does in chrome though?).
I have later found, It will work but only when its a <input> or other form control with the event handler. I think this is a bit sad, anyway around it? -
var keydownfunc = function(e){
-
if(!e)e=window.event;
-
-
if(window.event){e.returnValue = false;e.cancelBubble = true;}
-
else {e.preventDefault();e.stopPropagation();}
-
-
if(e.ctrlKey && e.keyCode == 83)
-
alert('Save Doc now');
-
document.focus();
-
}
-
-
window.addEventListener?
-
document.addEventListener('keydown',keydownfunc,false)
-
:document.attachEvent('onkeydown',keydownfunc);
-
Also note straight away I thought of google docs, soon found out the problem actually occurs in google doc's just the same.
Thanks. Josh
8 3200
I was looking at some other onkeydown event things, and I found that on quirksmode, the test app that was made, did supress the Ctrl-S. So I looked into the code and all I had to do from the start was simply return false in the handler :(
source: JavaScript - Detecting keystrokes
Im quite relieved actually, thought IE had an upper there for a while, dont understand why google docs does not use this though :S
Anyway, thanks for any time anyone put in, Josh
gits 5,390
Expert Mod 4TB
you could even use another JS-framework of course ... but to understand what those frameworks do for you and for what they are good for ... you should have such problems as you had ;) ... and know the solutions. to use a framework like jQuery, dojo, qooxdoo or whatever ... you should really need some more research regarding the things you really need or that you expect that you will need ... i'm not saying that jQuery is a bad recommendation but there are a lot of frameworks out there that might fullfill some different needs ...
kind regards
I am working on an editor, and it will likely turn out to be alot of script. So I am not sure if I want to run more script with a framework? Would a framework like Jquery add much loadtime / download time?
@Jezternz
Not at all, jQuery is a really lightweight javascript framework, you can download it packed, so it's really compressed, too. Frameworks like prototype + scriptaculous are kind of heavier, but nothing to worry about. you see, the vast majority of the sites use some javascript framework, and it really doesn't slow them down.
I use jQuery, because to me, is the smallest one, faster to learn, really flexible, and extensible.
gits 5,390
Expert Mod 4TB
you may have a look here for a quick comparison of different frameworks ...
kind regards
After looking into jQuery it looks truely amazing. I have a couple of questions about it though.
First what is the license like? Can you use your code (with the framework) commercially?
Secondly, just how efficient is it? will this add loading times or delays to your average user?
Thirdly, is it a good idea to commit to the JQuery framework, ie, will they be around for a while longer? are they reliable? (opinion off course)
@Jezternz
Take a look at the link gits posted, great resource to compare js frameworks.
- jQuery can be used commercially, there's no problem about it. http://docs.jquery.com/Licensing
It's the lightest js framework available.
They are truly reliable, his foundator (John Resig) is currently working with mozilla org, developing the upcoming js specification and working on the engine too.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Astra |
last post by:
Hi everybody
Wonder if you could help me out.
I created a simple JavaScript routine to enable a user to click backwards
and forwards between small news articles. This routine works fine in IE...
|
by: xxbmichae1 |
last post by:
I have a <select> object that i've set up an onchange event that fires
in IE fine when I use the cursor up and down in the list, but If I use
the cursor up and down in Firefox the event doesn't...
|
by: rich_poppleton |
last post by:
Help....
I've got a textarea where people type in a description. However for
certain reasons we need to stop them typing !$*^ .
I have a solution this which works fine in IE:
function...
|
by: Hillage |
last post by:
Hi,
It's possible to disable then online help in Firefox
when I press F1 key, using 'onkeypress' or 'onkeydown'
event?
Thanks in advance,
S. Hillage
|
by: Astra |
last post by:
Hi All
I have a JS routine to prohibit users from entering a range of chars in a
textbox and although this works perfectly in IE x, in the latest version of
Firefox it appears to be blocking...
|
by: Flomo Togba Kwele |
last post by:
For some reason, using Ctrl-leftarrow or Ctrl-rightarrow does not move the
cursor in VS2005. Opening the same VB file in Notepad, this function works by
skipping (or reverse skipping) to the next...
|
by: jonathandrott |
last post by:
Hi, i'm kinda new to vb.net and i'm trying to make an on screen
keyboard to use with a touch screen. how do i get it to print a
letter on the screen when the button is pressed in the textbox that...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |