For iOS google chrome, when a user hits the "Request desktop site" button what does the browser do to try to bring up a desktop site? I imagine some sort of header on the request that sites are looking for, or something similar?
对于iOS谷歌chrome,当用户点击“请求桌面站点”按钮时,浏览器会做什么来尝试打开桌面站点?我可以想象一些网站正在寻找的标题,或者类似的东西?
4 个解决方案
#1
50
I think the only difference is the User-Agent:
header in the request.
我认为唯一的区别是用户代理:请求中的头。
Here are the User-Agent headers sent by Chrome on my Android device:
以下是Chrome在我的Android设备上发送的用户代理标题:
Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76K) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.45 Safari/535.19
Notice the word "Mobile' in the first one, and also the mention of Android system and device. Checking these, I see that it also provides false information - namely X11 and x86_64 - to closely match the value sent by the Desktop Linux version of Chrome.
注意第一个词“Mobile”,还有Android系统和设备的介绍。检查这些,我发现它也提供了错误信息,即X11和x86_64,以与桌面Linux版本的Chrome的值相匹配。
#2
12
One other slight difference is that the request appears to have been to the last intentionally entered URL before any re-directors moved it. For example:
另一个细微的区别是,请求似乎是在任何重新执行董事移动之前,最后一次故意输入URL。例如:
Given: somesite.com sniffs the agent, sees Android, and does a document.location += "/m";
给定:somesite.com嗅探了代理,看到了Android,并做了一个文档。位置+ =“/ m”;
Then: the browser will have a URL of somesite.com/m
然后:浏览器将有一个somesite.com/m的URL。
But: if you "Request desktop site" it will change the User-Agent and re-request from somesite.com
但是:如果你“请求桌面站点”,它将会改变用户代理并重新请求somesite.com。
Unless: you had gone directly in on the mobile URL of somesite.com/m in the first place, in which case it just reloads somesite.com/m.
除非:你直接进入somesite.com/m的移动URL,在这种情况下,它只是重新加载somesite.com/m。
I would expect that this works with HTTP 301 and 302 redirects, I know it works with document.location changes (at least as described), and would speculate that it works with <meta> refreshes.
我希望这与HTTP 301和302重定向有关,我知道它与文档一起工作。位置更改(至少是这样描述的),并推测它与 刷新有关。
#3
7
Just wanted to point out that Chrome now not only changes the User-Agent
but also ignores the original viewport meta tag if you "Request Desktop Site". Thus it won't be necessary to sniff the User-Agent
anymore and you can rely on the viewport change as most responsive sites will automatically do. See this Change for further reference.
只是想指出,Chrome现在不仅改变了用户代理,而且如果你“请求桌面站点”,也会忽略原来的viewport meta标记。因此,不再需要对用户代理进行嗅探,您可以依赖于viewport的更改,因为大多数响应性站点都会自动执行。请参阅此更改以获得进一步参考。
#4
-2
This javascript snippet will effectively do the same :
这个javascript代码片段将有效地执行相同的操作:
function requestDesktopSite() {
document.getElementsByTagName('meta')['viewport'].content='min-width: 980px;';
}
<button onclick="requestDesktopSite()">Request Desktop Site</button>
#1
50
I think the only difference is the User-Agent:
header in the request.
我认为唯一的区别是用户代理:请求中的头。
Here are the User-Agent headers sent by Chrome on my Android device:
以下是Chrome在我的Android设备上发送的用户代理标题:
Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76K) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.45 Safari/535.19
Notice the word "Mobile' in the first one, and also the mention of Android system and device. Checking these, I see that it also provides false information - namely X11 and x86_64 - to closely match the value sent by the Desktop Linux version of Chrome.
注意第一个词“Mobile”,还有Android系统和设备的介绍。检查这些,我发现它也提供了错误信息,即X11和x86_64,以与桌面Linux版本的Chrome的值相匹配。
#2
12
One other slight difference is that the request appears to have been to the last intentionally entered URL before any re-directors moved it. For example:
另一个细微的区别是,请求似乎是在任何重新执行董事移动之前,最后一次故意输入URL。例如:
Given: somesite.com sniffs the agent, sees Android, and does a document.location += "/m";
给定:somesite.com嗅探了代理,看到了Android,并做了一个文档。位置+ =“/ m”;
Then: the browser will have a URL of somesite.com/m
然后:浏览器将有一个somesite.com/m的URL。
But: if you "Request desktop site" it will change the User-Agent and re-request from somesite.com
但是:如果你“请求桌面站点”,它将会改变用户代理并重新请求somesite.com。
Unless: you had gone directly in on the mobile URL of somesite.com/m in the first place, in which case it just reloads somesite.com/m.
除非:你直接进入somesite.com/m的移动URL,在这种情况下,它只是重新加载somesite.com/m。
I would expect that this works with HTTP 301 and 302 redirects, I know it works with document.location changes (at least as described), and would speculate that it works with <meta> refreshes.
我希望这与HTTP 301和302重定向有关,我知道它与文档一起工作。位置更改(至少是这样描述的),并推测它与 刷新有关。
#3
7
Just wanted to point out that Chrome now not only changes the User-Agent
but also ignores the original viewport meta tag if you "Request Desktop Site". Thus it won't be necessary to sniff the User-Agent
anymore and you can rely on the viewport change as most responsive sites will automatically do. See this Change for further reference.
只是想指出,Chrome现在不仅改变了用户代理,而且如果你“请求桌面站点”,也会忽略原来的viewport meta标记。因此,不再需要对用户代理进行嗅探,您可以依赖于viewport的更改,因为大多数响应性站点都会自动执行。请参阅此更改以获得进一步参考。
#4
-2
This javascript snippet will effectively do the same :
这个javascript代码片段将有效地执行相同的操作:
function requestDesktopSite() {
document.getElementsByTagName('meta')['viewport'].content='min-width: 980px;';
}
<button onclick="requestDesktopSite()">Request Desktop Site</button>