Wednesday, March 16, 2011

Javascript onchange functioning in a textarea (Symbian browser)

This may apply to other mobile operating environments than just Symbian... However, the issue is that when changing a text area field I'd like to update a count as I type. This is easy to accomplish in most browsers with something like this on the textarea tag:

onkeyup="document.getElementById('size').innerHTML=this.value.length;

However, in Symbian, the onkeyup event does not appear to fire normally (it seems like all input is buffered or something). Now I can replace this with:

onblur="document.getElementById('size').innerHTML=this.value.length;

...This works fine but of course only updates the DIV when focus is lost (which is better than nothing but not as nice as having it update as you type).

Has anyone encountered an issues like this specifically on Symbian? On any other mobile browser? Any ideas/solutions?

I've been hating Symbian since I've started using it -- there are so many weirdnesses like this in their APIs. I'll vote up anyone who gripes about Symbian. ;-)

From stackoverflow
  • In Symbian's version of WebKit, the keyboard events are royally messed up. The only reliable way to handle them is to set the handler on the document [!]. Now, I have NOT tried that in the situation where textarea has focus but it definitely works with simpler controls. Basically, you use the onfocus and onblur to associate/disassociate the control-specific event handlers with the document. Of course if you want to create a reusable widget that way, you're in for a sea of hurt :(

    OTOH, if you gripe about Symbian's little keyboard quirk, take a gander at mouse events in Android's mini-Chrome... those go under the FUBAR heading!

    ...Max...

    PS. If you need more help: max-at-motovilov-dot-com. You should be able to google for this issue on forum.nokia.com but the info there ain't plentiful... it's all trial and error.

    Andrew Flanagan : I've been using forum.nokia.com for a bit. I suppose there's some useful info there but it's usually not that great. I'm hoping Stack Overflow can become a better Symbian source. Thanks for the info!
    Pat : I can't get this to work even for the simplest textareas! can you update the answer with a working sample for a textarea?
    Andrew Flanagan : I actually never did as described. Differences between the emulator and the phone and curiously non-predictable results discouraged me from continuing. So I don't really have anything -- if you'd like I'd be happy to take a look at any code you've tried andrew dot flanagan at gmail _dot_ com.

0 comments:

Post a Comment