Detect if Silverlight is Installed

Back To: Silverlight Tutorials

Download code: SilverlightDetectionTest.zip

This page will hide the DIV containing the Silverlight plug-in and show a DIV that will display a message if Silverlight is not installed below. You can place content that you would like to show visitors who do not have Silverlight in the "noSilverlight" DIV.

Status of Silverlight:  
Silverlight is not installed

Code for this page:

<body>
Detect if Silverlight is Installed<br>
<br>
This page will hide the DIV containing the Silverlight plug-in and show a DIV 
that will display a message if Silverlight is not installed below: <br>
&nbsp;<div id="silverlightControlHost">
        <script type="text/javascript">
            createSilverlight();
        </script>
    </div>
    
    <div id="noSilverlight">
        Silverlight is not installed
    </div>
    <!-- Runtime errors from Silverlight will be displayed here.
    This will contain debugging information and should be removed or hidden when debugging is completed -->
    <div id='errorLocation'></div>
 
<script  type="text/javascript">
Silverlight.isInstalled(this);
if (Silverlight.available)
{
 showhide("noSilverlight");
}
else
{
 showhide("silverlightControlHost");
}
 
function showhide(id){ 
if (document.getElementById){ 
obj = document.getElementById(id); 
if (obj.style.display == "none"){ 
obj.style.display = ""; 
} else { 
obj.style.display = "none"; 
} 
} 
} 
</script>
 
<p>&nbsp;</p>
<p>Code for this page:</p>
<p>&nbsp;</p>
 
</body>
</html>

 

Back To: Silverlight Tutorials

Also See:


http://ADefwebserver.com

[About the author]