我用screen.width获取浏览器的宽度。它的罚款与iPhone Safari浏览器,但是在android手机没有工作(这表明800宽度的Android浏览器)。
i used screen.width to get the width of the browser. it worked fine with iphone safari but didn't work in android phone(it showed 800 width for android browser).
有没有兼容的方式来获取屏幕宽度。我不想使用用户代理,以检查它的移动浏览器。想使用JavaScript为和逻辑应包括屏幕宽度。
Is there any compatible way to get the screen width. I dont want to use UserAgent to check if its mobile browser. would like to use a javascript for that and logic should include screen width.
这是认识问题 - 看这里
It's know issue - see here
在第一次加载页面的 screen.width
和 screen.height
是错误的。
尝试这样的超时:
When page first loads the screen.width
and screen.height
are wrong.
Try a timeout like this:
setTimeout(CheckResolution, 300);
其中, CheckResolution
是函数。
上一篇:我该如何使用listDictionary?我该、如何使用、listDictionary
下一篇:安卓:"构造AlertDialog.Builder(新View.OnClickListener(){})是未定义"错误错误、未定义、AlertDialog、QUOT