如果用户在手机或平板电脑上查看,有没有办法让他们选择查看桌面版本? [英] Is there a way to give the user an option to view the desktop version if they are viewing on a phone or tablet?

查看:47
本文介绍了如果用户在手机或平板电脑上查看,有没有办法让他们选择查看桌面版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 TB 应该根据设备提供优化版本的内容,但我确实喜欢让用户控制他们如何查看网站的想法(即,如果他们愿意,让他们可以选择查看桌面版本它).

I know that TB is supposed to give optimized versions of content depending on the device, but I do like the idea of giving the user control over how they view the site (i.e. give them the choice to view desktop version if they want it).

推荐答案

如果单击桌面视图链接或基于用户代理,您可以加载不同的 CSS(无媒体查询).

You could load in different CSS (no media queries) if desktop view link is clicked or based on user agent.

如果您想要查看桌面版本的链接,您只需附加一个 GET/URL 变量,该变量会导致您的网站在没有媒体查询 CSS 或只有几个大宽度媒体查询的情况下加载.

If you want to have a link to view desktop version, you could just append a GET/URL variable that causes your site to load in without media query CSS or with only a few large width media queries.

如果您想利用 Chrome/Android 浏览器中的请求桌面站点"功能来提供桌面版本,则需要走用户代理路线.

If you wanted to utilize the 'Request Desktop Site' feature in Chrome/Android browsers to serve the desktop version, you would need to go the user agent route.

例如1.检查移动用户代理2.如果不是手机,不要加载媒体查询CSS3. 如果是移动设备,加载媒体查询 CSS 以启用响应式布局

For example 1. Check user agent for mobile 2. If not mobile, don't load media query CSS 3. If mobile, load media query CSS to enable the responsive layout

这确实削弱了响应式布局适应不同尺寸显示器或非移动替代设备的能力,仅对移动设备呈现响应.

This does take away from the ability of responsive layouts to adapt to different size monitors or non-mobile alternative devices, rendering responsive only for mobiles.

无论哪种方式,您都需要一些逻辑来处理 CSS 切换.如果使用 URL 变量来控制桌面视图,您可以使用 JavaScript 代码段轻松完成此操作.用户代理嗅探有点难看,最好使用您的本地编程语言来完成.

Either way you'll need some logic to hangle the CSS switching. If using URL variables to control desktop view you could do this pretty easily with a JavaScript snippet. User agent sniffing is a bit uglier and best done with your native programming language.

这篇关于如果用户在手机或平板电脑上查看,有没有办法让他们选择查看桌面版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆