Problem with focus in Input Field with RhoBrowser on MK3100.

M Michael Schillinger 3 years ago
57 2 0

Hi,

we have a problem on MK3100 with RhoBrowser showing an pricefinder application - so simple HTML/Javascript website with one input field with autofocus set. The problem is, that the autofocus doesn't work for the MK3100, however the same website is used on MK3000 with iExplorer and autofocus working. So I see the difference in the browser.

Website was created by our customer, using the following function for autocus.

  // den Fokus in das Feld der Artikelnummer legen
theForm.tbArticleNumber.focus();

My question is, how would you suggest to set autofocus within Rhobrowser?

Thanks,
Michael

Please register or login to post a reply

2 Replies

V Vedsatx Saddvv

Is there a reason you are using rho?  If you want it to work like the IE browser on the MK3000, you might have better luck using Enterprise Browser and selecting to deploy using IE instead of webit.  This should be equilvalent to running PocketBrowser.  It won't be exactly the same browser as the MK3000, but it would be more similar than the webkit browser in Rho or Enterprise Browser using Webkit.

Also, if you are running any of our custom browsers (rho, PocketBrowser, Enterprise Browser) there are javascript APIs for the scanner that would allow the developer to capture the barcode scanned without needing a field to have focus (I assume that's why they are trying to do this).

J Jon Tara

I'm not sure just what you mean by "autofocus". It's a new HTML5 feature:

http://davidwalsh.name/autofocus

I don't think that's what you mean, though.

What is it you are trying to accomplish, and how does it not work as expected?

You have two bits of code above, and not sure which one isn't doing as you expect.

1. You have some code (inline Javascript) that focuses a different field when tbArticleNumber is blurred.

2. You have some code that I guess tries to focus tbArticleNumber initially.

Which of these doesn't work?

You need to wait for document ready before (2). You didn't say if you are using jQuery, so can't tell you how to wait for document ready.

For (1) some browsers may require a timeout. I suggest not using inline Javascript.

If you are using jQuery:

$(document).on('blur', '.tbArticleNumber', function() {
setTimeout(function() {
  $('.tbArticleNumber').focus();
},0);

(Unclear what you are trying to do here, though. You are changing focus back to the same field?)

Note that the timeout value is 0. This should work for most/all browsers. This insures that the .focus() isn't attempted until after the blur event processing is completed.

Actually, you can probably just use autofocus attribute:

http://caniuse.com/#search=autofocus

CONTACT
Can’t find what you’re looking for?