如果客户端没有Silverlight运行时,则重定向页面

| 我想确定是否正在访问Silverlight Web应用程序的客户端安装了Silverlight运行时,否则,我想重定向到一个显示无法运行该应用程序的原因的aspx页面(而不是消息框告知缺少的Silverlight插件)。这个怎么做 ?
已邀请:
该Javascript提供了警告,我确信可以将其更改为重定向用户
function hasSilverlightPlugin() {
    var slplugin = false;
    var browser = navigator.appName; // Get the browser type

    if (browser == \'Microsoft Internet Explorer\') {
        try {
            var slControl = new ActiveXObject(\'AgControl.AgControl\');
            if (slControl) {
                slplugin = true;
            }
        } catch (e) { }
    }
    else {
        // Netscape, FireFox, Google chrome etc
        try {
            if (navigator.plugins[\"Silverlight Plug-In\"]) {
                slplugin = true;
            }
        } catch (e) { }
    }
    return slplugin;
}


/** This function checks the browser to see if Silverlight has been installed.
* The display informing the user that his/her browser is lacking the plugin
* is shown in the Announcements section of the desktop tab.
*/
function silverlightAnnouncementWarning() {
    var elem = null;
    var hasPlugin = hasSilverlightPlugin();
    elem = document.getElementById(\"SilverlightWaringElem\");
    if (!hasPlugin) {

        if (elem) {
            elem.style.display = \"\";
            var warningMsg = \"WARNING THE SILVERLIGHT PLUGIN IS NOT INSTALLED ON THIS MACHINE\"
            elem.innerHTML = warningMsg;
        }
    }
    //64 bit silverlight warning
    if (navigator.platform == \"Win64\") {
        if (elem) {
            var warningMsg = \"64 bit browser has been detected which is currently incompatible with Silverlight\"
            elem.style.display = \"\";
            var msg = elem.innerHTML;
            if (msg && msg.length > 0) {
                warningMsg = msg + \" (also a \" + warningMsg + \")\";
            } else {
                warningMsg = \"A \" + warningMsg;
            }
            elem.innerHTML = warningMsg;
        }
    }
}

function popupSilverlightWarning() {
    var hasPlugin = hasSilverlightPlugin();
    if (!hasPlugin) {
        var warningMsg = \"THE SILVERLIGHT PLUGIN IS NOT INSTALLED ON THIS MACHINE!\\n\";
        warningMsg += \"This page requires the Silverlight plugin in order to work.\\n\";
        warningMsg += \"Please contact your Systems Administrator to have the Silverlight plugin installed on this computer.\\n\";
        warningMsg += \"Thank you . . .\";
        alert(warningMsg);
    }
}
上面的JavaScript很不错,但是Silverlight 4.0在每个项目中都有一个不错的JavaScript文件,这使得这种类型的东西变得容易得多。 http://msdn.microsoft.com/zh-CN/library/cc265155(vs.95).aspx

要回复问题请先登录注册