是否支持css3

/**
     * Function to check css3 support
     * @param  {String}  declaration name
     * @return {Boolean}
     */
    function isCssSupported(declaration) {
        var supported = false,
            prefixes = 'Khtml ms O Moz Webkit'.split(' '),
            clone = document.createElement('div'),
            declarationCapital = null;

        declaration = declaration.toLowerCase();
        if (clone.style[declaration] !== undefined) supported = true;
        if (supported === false) {
            declarationCapital = declaration.charAt(0).toUpperCase() + declaration.substr(1);
            for( var i = 0; i < prefixes.length; i++ ) {
                if( clone.style[prefixes[i] + declarationCapital ] !== undefined ) {
                    supported = true;
                    break;
                }
            }
        }

        if (window.opera) {
            if (window.opera.version() < 13) supported = false;
        }

        return supported;
    }  

 

posted @ 2016-05-26 14:04  觉信  阅读(236)  评论(0编辑  收藏  举报