Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Browser - Javascript window.innerWidth returns wrong value

I am using the Android G1 default web browser, and I am developing in JavaScript - I have trouble getting the real visual width and height when I zoom in or out on a web page.

It seems that I am getting the wrong value out of window.innerWidth, when I am zooming in/out.

What I am trying to do is - showing an element on a visual fixed place, even when I am zooming and scrolling the page. - so the user can always see that element no matter if he is zooming or scrolling.

I already tried using position "fixed" with no success. The use of a viewport meta-tag is probably not a good solution since I don't want to limit the web page dimensions and I do want the zoom feature will be supported.

Does anyone have a solution or an idea how I can achieve this?

like image 808
user510468 Avatar asked Nov 17 '10 07:11

user510468


1 Answers

If your're trying to adjust element's position during zooming or scrolling, then it's a bad idea. WebView blocks DOM tree while performing these operations, so it doesn't display any changes you make from scroll and zoom events. Also I noticed that sometimes it fails to redraw DOM tree even after the last scroll or zoom event.

like image 182
Michael Avatar answered Sep 24 '22 02:09

Michael