如何使网站兼容手机和电脑
我在网上搜索了移动和 PC 浏览器上的 Web 应用程序兼容性,最后我决定。制作 2 个网站,一个用于移动浏览器,另一个用于 PC 浏览器。如何找出请求的是移动还是 PC 以及如何重定向移动或 PC 的网站。
如果还有其他兼容方式。请告诉我并为此提出好的建议
提前致谢
i searched on net for web apps compatibility on mobile and pc browser finally i decided.make 2 websites one is for mobile browser and other is for pc browser.how to find out requested is mobile or pc and how to redirect website for mobile or pc.
If there is any other way for compatibility.Please let me know and give your good suggestion for this
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗯,实际上你可以用不同的方式做到这一点。最好的解决方案是一些首先检查 UserAgent 的脚本。我知道,这并不是那么节省,因为更改代理很容易,但为什么有人要这样做以及这样做有什么好处;)
所以这应该是你的解决方案。您还可以针对特定的目标设备/浏览器优化网站。例如,对于 iPhone、Android 或 WinMob 等设备,您可以使用 Javascript 框架来处理网站内容。
我就另一个问题发表了一篇小文章,也可以帮助您:是否有涵盖 iPhone、Android、WebOS 和 Blackberry OS 的 jQTouch 等效版本?
Well, actually you can do it in different ways. The best solution is some script which checks the UserAgent first. I kow, its not that save, 'cause its easy to change the agent but why should someone do it and with which benefit of it ;)
So this should be your solution. Also you can optimize the websites to the specfic target device/browser. For example, for devices like iPhone, Android or WinMob you ould use Javascript Frameworks to work withthe website content.
I made a little post on another question which could help you aswell: Is there an equivilent of jQTouch that covers iPhone, Android, WebOS and Blackberry OS?
这并不像人们想象的那么简单。
首先,确定网络应用程序是否是从移动设备访问并不容易。什么是移动设备? iPad 是移动设备吗?所有分辨率小于1024*768的设备都应该被视为“移动设备”吗?
其次,设计一个 Web 应用程序以使其兼容所有不同的设备(进而可以安装许多不同的浏览器)并不是一件容易的事。
但幸运的是,也有一些解决方案。
有 WURFL -
http://wurfl.sourceforge.net/ - 其中
是一个开源替代方案。
设备图集 -
http://deviceatlas.com/ - a
商业替代方案。
Mobizoft C4M - http://mobizoft.com/ -
另一种商业替代方案
既是 API 又是一些
预打包的解决方案。
Wordpress 移动包 - http://wordpress.org/extend/plugins/ wordpress-mobile-pack/
其中任何一个都可用于将移动设备切换到特殊的移动适配网站。它们还可以用于构建/改编适合移动设备的网站,具体取决于您的需要。
当您构建了适合移动设备的网站时,您应该首先测试具有不同分辨率/操作系统/浏览器的设备。另一个有用的网站是 http://mobiready.com,您可以在其中验证该网站。
最后一个技巧是考虑支持哪些设备。仅限 iPhone/Android?也许有适用于这些设备的完整版本和适用于所有其他设备的简单版本。取决于你的要求是什么。
祝你好运!
This is not as simple as one may think.
First, determine if the web app is accessed from a mobile device is not easily done. What is a mobile device? Is iPad a mobile device? Should all devices with a resolution less than 1024*768 be handled as "mobile devices"?
Second, designing a web application to make it compatible for all different devices - which in turn can have many different browsers installed - is not a piece of cake.
But fortunately there are some solutions as well.
There is WURFL -
http://wurfl.sourceforge.net/ - which
is an open source alternative.
Device Atlas -
http://deviceatlas.com/ - a
commercial alternative.
Mobizoft C4M - http://mobizoft.com/ -
another commercial alternative with
both an API as well as some
prepackaged solutions.
Wordpress mobile pack - http://wordpress.org/extend/plugins/wordpress-mobile-pack/
Any of them can be used to switch a mobile device to a special mobile adapted site. They can also be used to build/adapt a mobile friendly site, depending on what you need.
When you have built an mobile friendly site you should first of all test it devices with different resolutions/os/browsers. Another useful site is http://mobiready.com where you can validate the site.
A final tip is to consider which devices to support. Only iPhone/Android? Maybe have a full version for these devices and a simpler version for all other devices. Depends what your requirements are.
Good luck!