简体   繁体   English

输入后滚动Phonegap iOS

[英]Scrolling Phonegap iOS after input

When a user inputs text on my Phonegap application then returned upon completion, the entire page is scrolled further than it should be. 当用户在我的Phonegap应用程序上输入文本,然后在完成后返回时,整个页面的滚动程度将超出其应有的范围。

I am looking for a workaround to ensure that, once unfocused, the page returns to it's normal position. 我正在寻找一种变通办法,以确保一旦失去焦点,页面就会恢复到正常位置。

See image that illustrates issue: 请参阅说明问题的图像:

http://i.imgur.com/ehdXCQq.png http://i.imgur.com/ehd​​XCQq.png

I am using iScroll 4.0 but it is not active on this page. 我正在使用iScroll 4.0,但在此页面上未激活。

How can this problem be rectified? 如何解决此问题?

The way forward was to set a Javascript event to take it back to the top of the page (or wherever) once focus has been lost on the input box. 前进的方法是设置Javascript事件,以在焦点失去输入框后将其返回页面顶部(或任何位置)。 This uses the onblur method (I guess the opposite of onfocus ?) and really simply states that once focus is lost, the page snaps back to the top. 这使用了onblur方法(我猜与onfocus相反),实际上只是简单地指出一旦失去焦点,页面就会回到顶部。

Here's the working sample: 这是工作示例:

<input name="foo" id="foo" class="foo" onblur="window.scrollTo(0,0);" type="text" />

...with, of course, onblur="window.scrollTo(0,0);" ...当然还有onblur="window.scrollTo(0,0);" being the operative code to return to the top of the page. 是返回到页面顶部的有效代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM