如何区分计算机和手机之间的设备 [英] How to defferentiate the device between computer and mobile
本文介绍了如何区分计算机和手机之间的设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问题:
我需要纠正设备,这意味着用户使用什么来打开手机或计算机页面
I need to rectify device ,I mean what user is using to open the page either mobile or computer
如果用户正在使用计算机,则需要在新窗口中打开链接,或者如果移动设备,则页面的链接应在同一窗口中而不是新窗口中打开
if user is using computer I need to open link in new window or if mobile the link of page should open in same window not in new
我需要在客户端进行操作,因为当前用户正在使用window.open方法打开页面
i need to do on client side because currently user is using window.open method to open page
谢谢
推荐答案
,您可以通过检查最流行的移动设备的用户代理来确定它(例如 所有移动浏览器的列表)或依靠浏览器的大小-但在最后一种情况下,当用户在桌面浏览器上以最小宽度打开页面时,您肯定会产生误报.
you may determine it either by checking user agent for most popular mobile devices (check e.g. List of all Mobile Browsers) or by relying on browser size - but in last case of course you will have false positive when user opens your page on desktop browser with minimized width.
这篇关于如何区分计算机和手机之间的设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文