robertybob
asked on
OnKeyPress workaround for IE Mobile
I am coding a very simple page that uses onkeypress to alter a formfield and then submit the form on the page. I would like to be able to use this page from my mobile device but I found info that tells me that IE Mobile doesnt support any Event captures.
Is there a workaround for this that utilises IE Mobile capabilities to the same end result?
Thx
Is there a workaround for this that utilises IE Mobile capabilities to the same end result?
Thx
ASKER
hi mplungjan - the code uses something like this to insert a word into the formfield. Works in normal IE, doesnt seem to work in FF but no probs at the moment.....main thing is to get it to work on IE Mobile
function keyHandler(e){
var pressedKey;
var selection;
if (document.all) { e = window.event; }
if (document.layers) { pressedKey = e.which; }
if (document.all) { pressedKey = e.keyCode; }
pressedCharacter = String.fromCharCode(presse dKey);
if(pressedKey=='97') { selection = 'Apple'; }
if(pressedKey=='98') { selection = 'Banana'; }
if(pressedKey=='99') { selection = 'Cherry'; }
document.boxform.word.valu e = selection;
}
document.onkeypress = keyHandler;
hope this helps :)
function keyHandler(e){
var pressedKey;
var selection;
if (document.all) { e = window.event; }
if (document.layers) { pressedKey = e.which; }
if (document.all) { pressedKey = e.keyCode; }
pressedCharacter = String.fromCharCode(presse
if(pressedKey=='97') { selection = 'Apple'; }
if(pressedKey=='98') { selection = 'Banana'; }
if(pressedKey=='99') { selection = 'Cherry'; }
document.boxform.word.valu
}
document.onkeypress = keyHandler;
hope this helps :)
For FF/NS/Mozilla and IE:
function keyHandler(e){
var pressedKey = (e) ? e.which : window.event.keyCode;
var pressedCharacter = String.fromCharCode(presse dKey);
if(pressedKey=='97') { selection = 'Apple'; }
if(pressedKey=='98') { selection = 'Banana'; }
if(pressedKey=='99') { selection = 'Cherry'; }
document.boxform.word.valu e = selection;
}
document.onkeypress = keyHandler;
Can you perhaps do
var fruit = { a: "Apple", b: "Banana", c: "Cherry"}
<input type="text" onKeyUp="if (fruit[this.value]) this.value=fruit[this.valu e]">
function keyHandler(e){
var pressedKey = (e) ? e.which : window.event.keyCode;
var pressedCharacter = String.fromCharCode(presse
if(pressedKey=='97') { selection = 'Apple'; }
if(pressedKey=='98') { selection = 'Banana'; }
if(pressedKey=='99') { selection = 'Cherry'; }
document.boxform.word.valu
}
document.onkeypress = keyHandler;
Can you perhaps do
var fruit = { a: "Apple", b: "Banana", c: "Cherry"}
<input type="text" onKeyUp="if (fruit[this.value]) this.value=fruit[this.valu
ASKER
the onKeyUp version doesnt trigger either :(
dont think IE Mobile allows any onkeydown, onkeyup, onkeypress, onmousemove, onmousedown and onmouseup events - not sure if there's a coding way round this or if MS have some kind of add-on package to boost the mobile IE functionality
dont think IE Mobile allows any onkeydown, onkeyup, onkeypress, onmousemove, onmousedown and onmouseup events - not sure if there's a coding way round this or if MS have some kind of add-on package to boost the mobile IE functionality
ASKER
Of course I'm only suggesting IE Mobile cos its on the device - if anyone can categorically confirm that these events are handled by another mobile browser which can also handle things like Ajax and all other IE capabilities then thats fine - I can try that if its free of charge.
Thx
Thx
I am frankly very surprised... I have a Nokia n80 and its browser can handle almost all javascript...
ASKER
Yup me too :) I have word that IE5 couldnt support this but IE6 can so i'm trying to investigate the software on the clients device tmrw. Tho its brand new and the spec says IE6 Mobile - will check with my own eyes on Monday and post here the conclusions.
ASKER
ok - it seems to be version 6.12 but definitely not allowing onkeypress :(
Super strange...
If you wish, ask for a PAQ and refund
If you wish, ask for a PAQ and refund
ASKER
lol :) i've just noticed that the OS is WInCE not Win Mobile so just investigating if this makes any difference
Great
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Robertybob, you still around? This is still a problem with Windows Mobile, but there is a dirty workaround, if you're still interested. Post another question (and give me a heads up). :)
how do you capture?
Do you have
<input type="text" onKeyPress="something(this
or is it
document.onkeypress=someth