Using JavaScript to autoscan on a galactic tablet

I am creating an application that will be mainly used on the Samsung Galaxy Tab. The application has a long form. The form occupies the entire screen of the tablet, so when you select a field, half of the form is covered with a keyboard. I want to be able to scroll the web page right where the input field is selected.

I tried 2 solutions:

1

var href = window.location.href; href = href.split("#")[0]; href = href + '#' + element.id; window.location.href = href; 

[2]

JQuery plugin: jQuery.ScrollTo

Both of these solutions work fine on desktop / portable browsers, but they don't seem to have any effect on the Galaxy browser for tablets. Does anyone have any ideas?

+4
source share
1 answer

First, I would try the $(htmlInputSelector)[0].focus() for this html element.

If this does not work, try:

  var myJqObj = $(htmlInputSelector); var hTop = myJqObj.offset().top; var hLeft = myJqObj.offset().left; window.scrollTo(hLeft, hTop); 
+2
source

Source: https://habr.com/ru/post/1442167/


All Articles