English 中文(简体)
PHP/javascript
原标题:Physical screen size detection based off user agent in PHP/javascript

因此,有办法检测移动浏览器和用javascript和php检查大小,但是,屏幕大小总是用纸浆回来,移动可以指这些日子。

我想能够知道,在移动时显示一个装置的大小如何,在任何地方,用桌子打什么。 之所以如此,是因为我想选择一个小屏幕装置的风格表,而其他一切都不符合正常风格。 例如,我想要一只白枪、火.、 h垫等显示正常的风格,但我想对手机或显示人手大小的任何装置采用不同的风格。

现在,我猜想做些什么来做这样的事,但也许有人会想更好的方式,或者知道某个地方具有筛选规模的数据库。

..maybe there s a way of finding pixel density and then applying the screen width/height in pixels to this..

问题回答

我实际上认为这是一个非常好的问题。 现在令人不满意的情况是,在10个“桌子上,当台式版仅被罚款时,你就在空洞的单一颜色“机动”现场服务。

不幸的是,正如约翰·亨特所发现的,甚至世界野生动植物群也没有准确的体格大小。

One semi-workaround is a heuristic assuming that if either the x or y dimension is less than 768 pixels then you are on a phone(*) and thus serve the single-column "mobile" version of your site by default.

您仍应始终允许访问者选择移动式或台式。 更可取的是,仅将其称为“s”或“lim”的贵址,以避免错误。

(*) Why 768 pixels? Because all 10" tablets of any importance are at least 1024x768 or 1280x800, whereas even phones with big screens such as the iPhone 5 or HTC HD5 have widths less than 768 pixels (iPhone 5 - 640x1136, HTC HD5 1280x720). This will probably not work on the giant samsung screens, but on those devices, having the desktop version served by default is not as annoying.

在使用字句时,烟雾功能的问题与将给板和电话设定“机动”旗号的问题相同。 我的问题是,如果我没有上页图像的顶端,我就希望电话能够进入一个有限的网页,以加快网站下载/下载。 桌子的出血率通常比3G要快,或比4gwifi低。

The responsive wordpress theme, Customizr, I m using uses the auto adapting twitter bootstrap, but still runs too slowly on phones with big image pages. So the question for my site is not just screen size or resolution, but data and screen draw speed.

Rocco Aliberti in this forum on themesandco s website made a useful suggestion combining a browser detection plugin that sets up an is_tablet function then combining it with the built in wordpress wp_is_mobile function to get "wp_is_mobile() && !is_tablet()" -e.g. the device is mobile and is not a tablet. http://www.themesandco.com/support-forums/topic/jetpack-mobile-issue/#post-23308

http://wurfl.sourceforge.net/nphp/

看像你can,从WURFLAmp.cool获得这种不清之处!

我认为,正确的答案是采用一种应对性的布局式办法,因为你永远不能让所有各种装置使用(每天有100个新装置)。

You can use frameworks like Bootstrap that show/hide columns or data based on screen resolution. This works nice as far as just displaying is concerned.

But ideally you would also want your scripting language to know this so that it would not process/execute certain data which is not going to get displayed by bootstrap.

At this moment browser agent does not provide screen resolution. Which should be enabled as modern websites have to be responsive to at least popular mobile, tablet and computer.

This is my wishlist for future versions of HTTP/W3c/Browser implementation.

you can check the screen size through javascript innerWidth gives/return the width of the device whether you are in the desktop or mobile phones, more filter you can you an user agent with this javascript innerWidth code.

之后,你可以根据屏幕大小应用这些芯片。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签