Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Member
Posts: 1
Registered: ‎08-23-2011
My Device: Torch 9800
My Carrier: AT&T

JavaScript element.focus() not working with some <input> types and <select>

I'm having these issue with the BlackBerry Torch 9800 on the standard web browser.

 

I have the following HTML form setup:

 

<input type="text">

<input type="password">

<input type="text">

<select>

<input type="submit">

 

I am using some JavaScript to override the enter-key functionality within the form to emulate a tab-key press to navigate the fields. Each time the onfocus event of one of these elements is fired I set the id of the next element in my input ordering into a JavaScript variable. I then have a function to intercept when the enter-key is pressed and instead of submitting the form I instead use the previously stored id and call it to focus.

 

I have tested this in Firefox 6, Safari 5, and IE8 with no trouble. I encounter issues in the Blackberry simulator.

 

I have no trouble tabbing from  and to <input type="text"> fields successively. When I reach a field of <input type="password"> the focus is drawn to it however upon tabbing again the focus sits on the password field. I am only able to resume tabbing if I click on the password field first.

 

I am also unable to use these functions to draw focus to <select> elements or <input type="submit"> elements.

 

Can anyone provide some help with this?

Developer
Posts: 49
Registered: ‎01-17-2010
My Device: Curve 9300

Re: JavaScript element.focus() not working with some <input> types and <select>

I realize that this post is a bit dated, but I'm running into this exact same problem.  Has anyone found a solution?

 

Thanks...

- Simulator 6.0.0.668 (9300)
- Windows 7 64bit
- Curve 9300 with App Version: 6.0.0.668 (2949)
Developer
Posts: 49
Registered: ‎01-17-2010
My Device: Curve 9300

Re: JavaScript element.focus() not working with some <input> types and <select>

Here's a complete HTML5 document that shows this problem with the BlackBerry browser:

 

<!DOCTYPE html>
<html>
  <head>
    <script>
      function getfocus() {
        document.getElementById('myInput').focus();
      }
    </script>
  </head>

<body>
  <input type="password" id="myInput">
  <br>
  <input type="button" onclick="getfocus()" value="Get focus">
</body>
</html>

 Save this as an html file and then open it in the BlackBerry browser.  When you press the "Get focus" button, notice that the input field appears to get focus, but you can't type in the field.  You have to explicitly click in the input field before you can type in it.  Is this a known bug with the BlackBerry browser?  Are there any workarounds?

 

Thanks...

- Simulator 6.0.0.668 (9300)
- Windows 7 64bit
- Curve 9300 with App Version: 6.0.0.668 (2949)
Developer
Posts: 49
Registered: ‎01-17-2010
My Device: Curve 9300

Re: JavaScript element.focus() not working with some <input> types and <select>

Bump...  I still can't figure this problem out.  Has no one solved this???

- Simulator 6.0.0.668 (9300)
- Windows 7 64bit
- Curve 9300 with App Version: 6.0.0.668 (2949)