设置 Page.ClientTarget = "uplevel" 的缺点是什么?对于所有页面?

发布于 2024-11-29 20:52:55 字数 638 浏览 0 评论 0 原文

我们最近遇到了问题,因为自 Firefox 4 发布以来,ScrollPosition 数据从未发送给 Firefox 用户。这是由于 browsercaps 文件仅指定 Firefox 3.x 的功能造成的。解决此问题的一种方法是在每台服务器上更新 browsercaps 文件,并在新版本的 Firefox(或 Chrome 或其他版本)发布时更新。好吧,在我们有机会解决这个问题之前,我们已经在使用 Firefox 6,而这似乎是一场我们不想继续进行的竞赛。

事实证明,在母版页中设置 Page.ClientTarget = "uplevel"(因此,对于所有内容,无条件地)可以修复我们特定的 Firefox ScrollPosition 问题。这种解决方案会带来哪些负面后果? Android 浏览器的用户体验会更差吗?他们现在是否只是要下载不必要的较大页面?我们有什么理由不应该这样做吗?

Page.ClientTarget 的文档非常可怕:

uplevel ,指定相当于 Internet 的浏览器功能 资源管理器 6.0。

..并且似乎是错误的,或者至少是误导性的。看起来它是在 IE6 还是功能最强大的浏览器的时代编写的。 “uplevel”真的意味着“假设浏览器具备一切能力”或“像对待 IE6 一样对待它”吗?

We've run into problems recently because as of Firefox 4's release, ScrollPosition data never gets sent to Firefox users. This is caused by the browsercaps file only specifying capabilities for Firefox 3.x. One solution to this problem is to update the browsercaps file on every server, and any time a new version of Firefox (or Chrome, or whatever) is released. Well, before we've even had a chance to address this problem, we're already on Firefox 6, and it just seems like a race that we don't want to keep running.

It turns out that setting Page.ClientTarget = "uplevel" in the master page (so, for everything, unconditionally) fixes our specific Firefox ScrollPosition issue. What are the negative consequences to this as a solution? Are users of Android browsers going to have a worse experience? Are they simply going to be downloading unnecessarily larger pages now? Is there any reason we shouldn't do this?

The documentation for Page.ClientTarget is pretty scary:

uplevel , which specifies browser capabilities equivalent to Internet
Explorer 6.0.

.. and seems wrong, or at least misleading. It seems like it was written at a time when IE6 was the most capable browser. Does "uplevel" really mean "assume the browser is capable of everything" or "treat it like you'd treat IE6"?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

新一帅帅 2024-12-06 20:52:55

如果您想告诉 WebForms 有效地“暂停”,那么设置 Uplevel 就可以了,尽管您想在早于母版页的 Page_Init 中执行此操作。此时,WebForms 将假设每个人的浏览器都比您自己的浏览器更新。

If you want to tell WebForms to effectively "lay off" then setting Uplevel works, although you want to do it in Page_Init which is earlier than the Master Page. At this point, WebForms will assume everyone is a newer browser than you're on your own.

悲凉≈ 2024-12-06 20:52:55

对于服务器端兼容性,无法测试浏览器的实际限制,我更喜欢使用黑名单而不是白名单:如果浏览器不知道支持功能X,那么我假设它支持它。

您还可以将所有版本的浏览器列入黑名单,例如,没有任何版本的 IE 支持功能 X)。这要求您在 IE 支持功能 X 后更新黑名单。

浏览器升级不应破坏此方案。

For server-side compatibility, which can't test the browser's actual limitations, I prefer using a blacklist instead of a whitelist: if a browser isn't known to not support feature X then I assume it supports it.

You can also blacklist all versions of a browser, e.g. no version of IE supports feature X). this requires you to update the blacklist once IE does support feature X.

Browser upgrades shouldn't break this scheme.

伴我心暖 2024-12-06 20:52:55

这不是“缺点是什么”问题的答案,而是:

您可以在 browsercaps 文件中的浏览器版本检测中使用正则表达式。

例如,2011 年 11 月 13 日,Microsoft 发布了 ASP.NET 4.0 的更新,将 IE10 添加到了高级列表(并修复了位于 \Windows 中的 ie.browser 文件中的错误) \Microsoft.NET\Framework\v4.0.30319\Config\Browsers)。他们有一个正则表达式,仅检查个位数的主要版本,但在补丁之后,任何 IE 版本 >= 6 将被视为高级版本。

更改之前: 更改

<capability name="majorversion" match="[6-9]" />

之后:

<capability name="majorversion" match="[6-9]|[1-9]\d+" />

我猜您不会再遇到这个问题了,因为至少从 2011 年 10 月 26 日开始,firefox 指令还使用正则表达式来检测上层版本 >= 3:(来自firefox.browser 文件),

<browser id="Firefox3" parentID="Firefox">
    <identification>
        <capability name="majorversion" match="^[3-9]|[1-9]\d+" />
    </identification>

    <capabilities>
        <capability name="javascriptversion"               value="1.8" />
        <capability name="supportsMaintainScrollPositionOnPostback" value="true" />
    </capabilities>
</browser>

但如果您仍然遇到问题,只需使用具有前瞻性的正则表达式(不存在“个位数主要版本”错误的正则表达式,例如在早期的补丁中)在 firefox.browser 文件中

This is not an answer to the "what are the drawbacks" question, but:

You can use regular expressions in the browser version detection within the browsercaps files.

For example, on November 13, 2011 Microsoft released an update for ASP.NET 4.0 that added IE10 to the uplevel list (and fixed a bug in the ie.browser file, located in \Windows\Microsoft.NET\Framework\v4.0.30319\Config\Browsers). They had a regular expression that only checked for single-digit major version, but after the patch any IE version >= 6 will be considered uplevel.

Before the change:

<capability name="majorversion" match="[6-9]" />

After the change:

<capability name="majorversion" match="[6-9]|[1-9]\d+" />

I'm guessing you are not running into this problem any more, because at least as of 26 October 2011, the firefox directive also uses a regex to detect as uplevel versions >= 3: (from the firefox.browser file)

<browser id="Firefox3" parentID="Firefox">
    <identification>
        <capability name="majorversion" match="^[3-9]|[1-9]\d+" />
    </identification>

    <capabilities>
        <capability name="javascriptversion"               value="1.8" />
        <capability name="supportsMaintainScrollPositionOnPostback" value="true" />
    </capabilities>
</browser>

but if you are still having probs, just use a forward-thinking regex (one that does not have a "single digit major version" bug like in earlier patches) in the firefox.browser file

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文