简体   繁体   English

确定网页是否适用于移动设备的最佳方法是什么?

[英]What is the best way to determine if a web-page is for mobile?

Should I scan for tags in the html code? 我应该扫描HTML代码中的标签吗? Or what? 或者是什么? What determines whether a page is optimized for mobile? 什么决定了页面是否针对移动设备进行了优化

One option is to scan for tags. 一种选择是扫描标签。 If so, what other tags are there? 如果是这样,还有哪些其他标签?

<link rel="apple-touch-icon" href="..." />
<meta name="viewport" content="width=device-width, user-scalable=no" />

Another option is to see if the HTML returned from a mobile user-agent is smaller than the HTML returned from a desktop browser. 另一种选择是查看从移动用户代理返回的HTML是否小于从桌面浏览器返回的HTML。 user agent... 用户代理...

Any thoughts? 有什么想法吗?

One option: look for: <meta name="MobileOptimized" /> 一个选项:寻找: <meta name="MobileOptimized" />

Another: <meta name="HandheldFriendly" content="true"/> 另一个: <meta name="HandheldFriendly" content="true"/>

Another: doctype is either XHTML-MP or WML (or other mobile-friendlies). 另一个:doctype是XHTML-MP或WML(或其他移动友好)。

Here's a usefuil link for sniffing out different smartphones using JavaScript. 这是一个usefuil链接,用于使用JavaScript嗅探不同的智能手机。

http://www.hand-interactive.com/resources/detect-mobile-javascript.htm http://www.hand-interactive.com/resources/detect-mobile-javascript.htm

However, its worth paying attention to the caveats in the above link. 但是,值得关注上述链接中的警告。 Particularly, the fact that we are browser sniffing, which is inherently unreliable (I recently got a hit on my website for MSIE 999.1) 特别是,我们是浏览器嗅探,这本质上是不可靠的(我最近在我的网站上获得了MSIE 999.1的热门话题)

What exactly are you trying to accomplish? 你到底想要完成什么?

Officially, there is no such thing as a mobile page. 正式地说,没有移动页面这样的东西。 It's perfectly possible to create a page that works equally well on mobile as on desktop browsers. 完全可以创建一个在移动设备上同样适用于桌面浏览器的页面。 Hell, if you just make a page with simple html and no styling it will already do that. 好吧,如果你只是制作一个简单的html页面而没有样式,那么它就已经做到了。

These days we often see seperate mobile pages, but usually this is an indicator that the design of the 'normal' page was not thought-through. 这些天我们经常看到单独的移动页面,但通常这表明“普通”页面的设计没有经过考虑。

Long story short, you could never detect this 100% because there's no real difference. 长话短说,你永远无法发现这100%,因为没有真正的区别。

If you want to find out whether or not a browser is mobile or not, check this out: http://wapl.info/coding-for-the-mobile-web-with-WAPL/chapter/isMobileDevice-via-CURL/ 如果您想了解浏览器是否可以移动,请查看以下内容: http//wapl.info/coding-for-the-mobile-web-with-WAPL/chapter/isMobileDevice-via-CURL/

Pass through all of your headers, and the web service will do the rest. 通过所有标题,Web服务将完成剩下的工作。

Better than detecting mobile with javascript, or looking for specific tags - do it before you even start outputting anything to the screen. 比使用javascript检测移动设备或寻找特定标签更好 - 在您开始向屏幕输出任何内容之前执行此操作。

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

相关问题 当用户在网页上时,定期询问用户是否希望保持登录状态的最佳方式是什么? - What is the best way to periodically ask a user if they wish to remain logged-in when the user is on a web-page? 如何使用chm文件确定正在打开哪个网页 - How determine what web-page is opening using chm-file 确定网页已被激活(包括切换浏览器选项卡)的最佳方法是什么? - What is the best way to determine your web page has been made active (including switching browser tabs)? 网页边界值 - Web-page boundary values 在网页中查找 Function - Find a Function in Web-Page 打开和隐藏网页 - Opening and hiding web-page 较长网页上的下拉菜单 - Dropdown on a longer web-page 如何将第一个文档的引荐来源网址加载到网络浏览器中以确定网页的打开方式 - How do I get referrer of first document loaded into webbrowser to determine how web-page opened 如何“最好”地允许网页访问者构建数学或统计工具? - How “best” to allow a web-page visitor to construct mathematical or statistical tools? 如果 JavaScript 很少发生,我可以使用什么工具找出网页挂起的原因? - What tools I can use to find out what JavaScript hangs the web-page if it occurs rarely?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM