zoukankan      html  css  js  c++  java
  • 检查浏览器是否有此插件如flash

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <title>navigator对象</title>
    </head>
    
    <body>
        <button onclick="checkFlash()">检测</button>
        <p style="color: red">检测是否有flash插件</p>
        <script>
        // 检测非IE插件
        //name是插件名称
        function hasPlugin(name) {
            name = name.toLowerCase();
            for (var i = 0; i < navigator.plugins.length; i++) {
                if (navigator.plugins[i].name.toLowerCase().indexOf(name) > -1) {
                    return true;
                }
            }
            return false;
        }
        //检测IE插件name为插件的标识符
        function hasIEPlugin(name) {
            try {
                new ActiveXObject(name);
                return true;
            } catch (ex) {
                return false;
            }
        }
        //检测是否有flash插件
        function hasFlash() {
            var result = hasPlugin("Flash");
            if (!result) {
                result = hasIEPlugin("ShockwaveFlash.ShockwaveFlash");
            }
            return result;
        }
    
    
        function checkFlash() {
            var resultChecker = hasFlash();
            if (!resultChecker) {
                var message = confirm("您的浏览器未安装Flash插件,现在去安装?")
                if (message) {
                    window.location.href = "http://get.adobe.com/cn/flashplayer/";
                }
            } else {
                alert("安装Flash插件");
            }
        }
        // checkFlash()
        </script>
    </body>
    
    </html>
    
    
    
  • 相关阅读:
    冒泡排序&快速排序
    1252. Cells with Odd Values in a Matrix
    位运算小结
    832. Flipping an Image
    1812. Determine Color of a Chessboard Square
    10、属性、构造函数与析构函数
    09、封装与类成员
    07、面向对象简介
    06、C#异常处理
    03、运算符
  • 原文地址:https://www.cnblogs.com/hyx626/p/10365074.html
Copyright © 2011-2022 走看看