有没有办法使用App_Browsers文件来检测支持HTML5文件API的机会吗? [英] Is there a chance to use App_Browsers to detect support of the HTML5 File API?

查看:217
本文介绍了有没有办法使用App_Browsers文件来检测支持HTML5文件API的机会吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 HTML5文件API 上传文件,我目前使用的一些硬支持它们,这取决于用户代理字符串浏览器的codeD检查:

Using the HTML5 File API to upload files, I am currently using some hardcoded checking of the browsers that support them, depending on the user agent string:

internal bool IsHtml5FileUploadCapable
{
    get
    {
        var browser = Request.Browser;

        var n = browser.Browser.ToLowerInvariant();
        var major = browser.MajorVersion;
        var minor = browser.MinorVersion;

        return
            n.Contains(@"chrome") && major >= 6 ||
            n.Contains(@"ie") && major >= 10 ||
            n.Contains(@"firefox") && (major >= 3 && minor > 6 || major >= 4) ||
            n.Contains(@"opera") && (major >= 11 && minor >= 5 || major >= 12) ||
            n.Contains(@"safari") && major >= 4;
    }
}

我爱用的是内置的App_Browsers文件的功能与<连词href=\"http://msdn.microsoft.com/en-US/library/system.web.httpbrowsercapabilities_members%28v=VS.80%29.aspx\"相对=nofollow> 的HttpBrowserCapabilities 类。

我的问题:

是否可以推断出一个浏览器来直接从浏览器功能,支持HTML5文件API的能力?

Is it possible to deduce the ability of a browser to support the HTML5 File API directly from the browser capabilities?

推荐答案

这可能不是你问什么事情,但其对JavaScript库一看,被称为Modernizr的(的 http://www.modernizr.com/docs/ ),可能是你的用例是有用的。它的,当然,客户端检查和不服务器端之一。

It may not be exactly what you are asking about, but having a look on the javascript library, called Modernizr ( http://www.modernizr.com/docs/ ), might be useful for your usecase. It's, of course, client-side check and not server-side one.

这是能够检测相当多的HTML5特性。

It is capable of detecting quite a lot of HTML5 features.

这篇关于有没有办法使用App_Browsers文件来检测支持HTML5文件API的机会吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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