检测浏览器中是否安装了插件


Detect if plugin is installed in browser

在我的网站上,我使用搜索浏览器插件。在网站的底部,它有一个对象来添加浏览器插件到您的浏览器。如果插件安装在而不是,则会显示此内容。但是如果安装了插件,内容就不应该显示了。我有自动加载Javascript代码,应该检查你是否安装了插件。如果是真的,那么内容应该被隐藏起来。但这行不通。var isInstalled总是0

这是我的Javascript代码:
<script type="text/javscript">
    function check () {
            var isInstalled = extender.IsSearchProviderInstalled("http://www.soseek.org?q=x%s");
            if (isInstalled) {
                document.getElementById("s_button").style.visibility = "hidden";
                document.getElementById("l_button").style.visibility = "hidden";
            }
    }
</script>
</head>

我该如何解决这个问题?

我找到了关于IsSearchProviderInstalled的文档,它只适用于InternetExplorer 7+,并以这种方式使用:

<head>
    <script type="text/javascript">
        function IsInstalled () {
            if (window.external && window.external.IsSearchProviderInstalled) {
                var isInstalled = window.external.IsSearchProviderInstalled ("http://www.dottoro.com");
                if (!isInstalled) {
                    window.external.AddSearchProvider ("searchProvider.xml");
                }
            }
            else {
                alert ("Your browser does not support the IsSearchProviderInstalled method!");
            }
        }
    </script>
</head>
<body>
    <button onclick="IsInstalled ()">Add search engine if not installed</button>
    <br /><br />
    To manage search engines, open the drop-down menu of your browser's Search Box (Firefox and Internet Explorer)
    or select Options/Basics/Default Search/Manage (Google Chrome).
</body>

来源:http://help.dottoro.com/ljfslnsp.php