I need to know the px size of the input field with focus at the top of the screen. To give a scrollTOP and the field in focus stay at the top of the screen.
The problem idea is as follows:
I'm working on mobile, and I'm using hybrid methods to develop, for this reason I have HTML5
, CSS3
, JQUERY
among other web medium to develop. I need a generic solution so that any page that the person is browsing, it will take the field being typed and place it at the top of the page. The page in the sense of div
, since each div
is a view
, the div
being viewed has the display: block
, but the rest are with display: none
.
Using the specifications how to develop?
I started to do some things but I do not know to continue, it follows the code:
window.addEventListener("resize", function() {
is_keyboard = (window.innerHeight < initial_screen_size);
is_landscape = (screen.height < screen.width);
updateViews();
}, false);
function updateViews() {
// $("#ajusteTeclado").show();
console.log("Entro aqui.");
var elmnt = document.getElementById("login");
elmnt.scrollTop = 500;
$('#login').css('top','100px');
}
But as I used it all manual I need to get the field in focus.