First time here?

You are looking at the most recent posts. You may also want to check out older archives. Please leave a comment, ask a question and consider subscribing to the latest posts via RSS or email. Thank you for visiting!

I’m hoping this post will help explain a few things with regard to Silverlight detection scripts that some sites may be using.  This is related to the silverlight.js Javascript file that was deployed with a lot of Silverlight 1.0 applications/sites and is also available as a part of the Silverlight 2 SDK tools.

What the heck is this Silverlight.js you speak of?

Simply put, Silverlight.js is a helper file which enables Web sites to create advanced Silverlight installation and instantiation experiences.  It was a resource file that was initially shipped along side several templates and helper projects to aid in the detection of browsers and platforms and instantiate a new Silverlight application on a web page.  This actually was a method similar to other frameworks that used Javascript to instantiate plugin content to provide for a better user experience in some deployment instances.  When delivering rich internet applications, it is important to provide your users with the most positive experience in installing any plugins they may require.  You can read more about my thoughts about that here in Providing a great Silverlight deployment experience.

Although not generally used for Silverlight 2 deployment now in favor of simply using the <object> tag explicitly, it is still a resource available to site developers should they choose to use it.  It provides some simple functions like checking if Silverlight is installed, and a method to create the HTML output content for when it is (object) and when it is not (HTML content).

So why is it being updated, is something totally wrong?

Not really.  We received feedback on some areas of the file and some scenarios where an enhanced version of certain aspects should be modified.  As an example, after the plugin was installed (by a user who previously did not have Silverlight), the browser had to be refreshed (and in some cases restarted) prior to the Silverlight plugin being able to be used.  This was one area of feedback that we heard and while some script methods surfaced as work arounds, ultimately they ended up being incorporated into this newer Silverlight.js file.

Some of the enhancements provided in this update are:

    • Auto-refresh behavior where available, providing WaitForInstallation and onSilverlightInstalled hooks for developers to use.
    • Reduced clicks in the default installation badge
    • Inproved UI for default badge image (i.e., looks better on all sites)

Although they may seem minor, they help in enabling site owners deliver great deployment experiences.

Great, so where can I get this update?

The updated Silverlight.js file has been available for a while in the Silverlight 2 SDK materials.  However, you have had to download the full Silverlight 2 SDK just to get to the one file you may need.

NOTE: If you have already done this, the file is located in C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Tools path.

Today, we actually made it available on its own without having to download the full Silverlight 2 SDK (but you should really check out Silverlight 2…it’s really great).  Leveraging the MSDN Code Gallery, the Silverlight.js file is now available for download as a stand-alone file at the Silverlight.js Code Gallery project site.  A link to the API documentation and any breaking changes from the previous version are also available there.  What is further great is that it is being released under the Microsoft Public License (Ms-Pl), which means it is available for you to freely modify to your own needs.

I got the file, how and what should I be updating with this new file?

Now that you have the updated file, what do you do with it.  Well, that depends :-).  The simplest answer here is to replace your old Silverlight.js file with this new one.  IMPORTANT: Review the breaking changes documentation to ensure you aren’t using things that may break.  If you never knew you were even using the Silverlight.js file you should generally be safe with a simple replace.  Your old file will likely be sitting in your web application and named Silverlight.js…just copy this file over that one (I’d recommend backing up your old one just in case).

There may be other areas where you want to update the file so that you don’t have to update the file to begin with.  Now, please note this is a suggestion from me and likely ‘unsupported’ but I feel pretty safe about updating these templates.   Here are some suggestions:

Visual Studio 2005 Project Templates

If you are using VS2005, you probably downloaded the Silverlight 1.0 SDK which installed some VS2005 project templates for your creating Silverlight 1.0 applications.  Look for the template file in C:\users\(username}\Documents\Visual Studio 2005\Projects\Templates\ProjectTemplates\Silverlight\SilverlightJSApplication.zip.  This is the path on Vista, but the user path is slightly different on Windows XP (c:\documents and settings…etc.).  If you open that archive you’ll see the Silverlight.js file there.  Now, please note this is a suggestion from me and likely ‘unsupported’ but I feel pretty safe about updating this template.  Simply use your favorite archive tool to open the template file and replace the Silverlight.js file with the new one.  Now when you choose File…New…Silverlight Javascript Application in Visual Studio 2005 you’ll have the updated Silverlight.js file already!

Visual Studio 2008 Project Templates

NOTE: These actually shouldn't need updating if you are using the latest Silverlight 2 Beta 2 SDK tools...the templates already have the update in them.

If you are using VS2008 you are likely using Silverlight 2 development (which the project templates do not use Silverlight.js), but there actually is a Silverlight Script Web project type for still working on 1.0 projects.  The location of that template is C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\Web\{language}\1033 where language is both CSharp and VisualBasic (there is a template for both).  Within this folder is an archive file called SilverlightScriptWeb.zip which is the template file.  If you open that archive you’ll see the Silverlight.js file there.  Simply use your favorite archive tool to open the template file and replace the Silverlight.js file with the new one.  Now when you choose File…New Web Site…Silverlight Script Web in Visual Studio 2008 you’ll have the updated Silverlight.js file already!

Expression Encoder Output Templates

All of the Expression Encoder media output templates use this file.  This process is a bit more time because there are more templates than just two.  Navigate to C:\Program Files\Microsoft Expression\Encoder 2\Templates\en to see the templates.  If you have Encoder 1 installed the path will be different slightly in C:\Program Files\Microsoft Expression and might be called Media Encoder depending on what version you have (but you really should get Encoder 2, it rocks).  In each of those template folder you’ll see the Silverlight.js file there.  Again, I’d recommend backing this up ‘just in case’ before making any changes.  Since none of these are in an archive folder, you can copy/paste the file into each of the template folders.  If you have Powershell installed you can navigate to the run this command (nod to ScottHa for the help):

   1: dir . silverlight.js -recurse |% { copy c:\foo $_.FullName  }

obviously replacing {c:\foo} with the location of where you downloaded the updated Silverlight.js file.  One note here is that the Encoder templates included an obfuscated/compressed version of Silverlight.js.  The new one is not compressed/obfuscated and you should test your templates to ensure everything works.

Does this fix any Firefox 3 issues?

It’s important to note that Firefox 3 is not currently a supported browser for Silverlight.  At the time of release of Silverlight 1.0, Firefox 3 was not a released product.  And right now Silverlight 2 is still in beta as well.  We intent on making Firefox 3 a supported browser when Silverlight 2 releases this year.

That said the updated file will likely fix one problem with Firefox 3 visiting sites that use Silverlight.js.  Using the old file, visitors using Firefox 3 would see an image asking them to install Silverlight even though they already had it installed.  We’ve made some updates to the isInstalled method to cover the Firefox 3 scenario so this won’t happen.

You can see an example I put up on my server by visiting the same Silverlight application using the old script or the new script.  The only difference between these two is a cut/paste of Silverlight.js.


NEW (replacing only silverlight.js):

Attention site owners:  If you are seeing information from your users or haven’t tested your Silverlight applications in Firefox 3, please do so and update to the latest Silverlight.js file if you are using the old one.  Visitors, if you see sites that are displaying the ‘install Silverlight’ badge and you have Silverlight installed, you can try to contact them and refer them to this post…or leave a comment here as well.  Yes, I know some Microsoft sites need this update as well, we’re working on getting the site owners to update as well!

I saw a link about Silverlight.supportedUserAgent.js as well, what is that?

This file is an optional add-on for Silverlight.js. It adds Silverlight.supportedUserAgent function which determines if the user's browser is supported by Silverlight.  This is not included in the base because supportedUserAgent is highly dependent upon the current Web browser implementations.  Because browsers evolve, this file would need to be updated more frequently than Silverlight.js.  If you need this functionality, you’ll want to check back often to get any updates.  The supportedUserAgent file has a Code Gallery project site as well.

I hope this helps clear up some confusion and provide some pointers where you might want to update.  If you have any questions, leave a comment and I’ll do my best to answer!

This work is licensed under a Creative Commons Attribution By license.

7/6/2008 11:02 AM | # re: Updating Silverlight.js and Firefox 3
Thanks alot, this was very helpful
7/6/2008 4:39 PM | # re: Updating Silverlight.js and Firefox 3
Hey Now Tim,

This is a great post. Very informative.

Thx 4 the info,
7/8/2008 2:08 AM | # re: Updating Silverlight.js and Firefox 3
this site keeps prompting me

7/8/2008 9:03 AM | # re: Updating Silverlight.js and Firefox 3
Thanks Kevin -- that one is on my radar as well!
7/9/2008 7:19 AM | # re: Updating Silverlight.js and Firefox 3
Hi Tim,

Firstly thank-you greatly for this post. Was very helpful.

I'm still having a problem with my encoder 2 template in firefox3. I've got the Silverlight runtime version 2.0.30523 on my machine.

My video and player are hosted here:

It doesn't play! The funny thing is if I set the mediasource to your hosted video (Bear.wmv), it works fine. Like this:

On a test machine I only installed the Silverlight 1 runtime and both urls worked. Any ideas or comments would be greatly appreciated. Thanks in advance.

7/9/2008 7:38 AM | # re: Updating Silverlight.js and Firefox 3
Hi Tim,

Apologies, I posted the wrong url's previously.

This is where I'm trying to play my hosted video:

This is where it plays your hosted video:


8/12/2008 8:57 AM | # re: Updating Silverlight.js and Firefox 3
Silverlight will not install on my machine. A popup for the Amyuni PDF converter comes up, and I keep getting the same error message:
Installing PDF printer.
Error code: 1801
The printer name is invalid.
Printer setup failed.
Error code: 1801
The printer name is invalid.

As far as I can tell, Silverlight isn't installed anywhere on my machine.

The beta2 SDK unzips just fine, but the updated .js file has no impact because the guts of Silverlight aren't to be found.
8/12/2008 9:10 AM | # re: Updating Silverlight.js and Firefox 3
MarkK: the silverlight.js file is for site developers, not for end users. It is NOT something you would put on your desktop to get Silverlight to work. The site owner, if using an older version of this file, needs to deploy it to their server application.
8/27/2008 12:16 PM | # re: Updating Silverlight.js and Firefox 3
Hi Tim,

has this fix been rolled out for Silverlight Streaming Services?


9/1/2008 3:29 PM | # re: Updating Silverlight.js and Firefox 3
Hi Tim

I still have issues with Firefox 3 even by using the latest Silverlight.js. I would like to uninstall silverlight on FF3 and restart from fresh, but apparently I don't see how to remove the plugin. I can disable it but can't install.
I tried using your sample page, and the download Silverlight button is there even if Silverlight is installed and enabled.
Any news about the compatibility with FF3? Because with all the push Firefox team has done to get their users moving to the version 3 I am afraid Silverlight will be soon pointless if nothing is done quickly from Microsoft!
Thanks for the good help ;-)
9/1/2008 3:34 PM | # re: Updating Silverlight.js and Firefox 3
Hi Tim

Another thing. Can you tell me where to find an example of the OBJECT method you mentioned to detect silverlight?
I try one of your earlier post but no success. Now what I am trying to do is to use the standard Mediaplayer object in ASP.Net and I would like to have my own link to Silverlight install.
Any idea?

12/19/2008 1:58 PM | # re: Updating Silverlight.js and Firefox 3
Hi everyone, I replaced the silverlight.js and Still i can't see my project in FireFox 3, what esle i can do? I can see it only in IE7. I'm Using VS2008 I have everything install in my pc, All silverlight etc etc etc.

3/10/2009 10:44 PM | # re: Updating Silverlight.js and Firefox 3
I replaced Silverlight.js and yes, I no longer get the annoying badge in Firefox 3. However, it is clear that SL is not instantiating. The standard code for getting the plugin fails miserably and simply returns an 'object not found'. Is there also a problem with addressing the plugin in FireFox?

I'm using a standard creator for the plugin:

function createSilverlight()
var scene = new mapItXAML.Page();
source: "Page.xaml",
parentElement: document.getElementById("silverlightControlHost"),
id: "SilverlightControl",
properties: {
width: "100%",
height: "100%",
version: "2.0"

Note that my control id is 'SilverlightControl'.

If I attempt to access that control and do something like this:

var mainGrid = SilverlightControl.content.findName("mainGrid");

This will fail with object not found. For that matter, I cannot get a handle to the object any way, even with something like getElementById('SilverlightControl'). This will not fail, but simply return null. It is clear the silverLight object isn't getting instantiated.

This occurs only in FireFox 3. Chromium, Safari 3 / 4, and IE are all happy.

Any ideas?
3/10/2009 11:23 PM | # re: Updating Silverlight.js and Firefox 3
Tom can you point me to your implementation or send me some code? I notice that you are using Page.xaml, but set the version to 2.0 as well...a bit of a mismatch.
4/13/2009 5:24 PM | # re: Updating Silverlight.js and Firefox 3
Hey Tim,
I was going through your tutorial and used Encoder 2 to create a video player template that I can customize, I followed your instructions in the video to encode the video. I opened the output folder and tried to run the html file that was created in firefox 3 but I got the Install Silverlight prompt. After reading this blog I understood that the issue was with the Silverlight.js in the template folder but I was not sure since I was using all the latest versions. But anyway I looked up the templates in the encoder 2 folder and I noticed that the Silverlight.js was version 1.0, when I replaced that it did start working. But isn't it weird that the install team for encoder 2 did not catch this or was it intended to be released with version 1.0??

Luis/Paschal - I think you guys have the same issue.
4/13/2009 7:43 PM | # re: Updating Silverlight.js and Firefox 3
Chris -- duly noted...I'll remind the team.
9/11/2009 8:36 AM | # re: Updating Silverlight.js and Firefox 3
I have the silverlight 3 sdk - Expression Web Creates a silverlight.js file when encoder is run to create the SL video. It creates the following code on the page:

<object data="data:application/x-silverlight-2" type="application/x-silverlight-2" width="720" height="480">
<param name="source" value="silverlightvideos/QuikSilverTemplate.xap"/>
<param name="background" value="white" />
<param name="minRuntimeVersion" value="3.0.40624.0" />
<param name="autoUpgrade" value="true" />
<param name="enableHtmlAccess" value="true" />
<param name="enableGPUAcceleration" value="true" />
<param name="initparams" value='playerSettings =

The silverlight.js created by the encoder refers to:

var actualVer = plugin.description;
if ( actualVer === "1.0.30226.2")
actualVer = "2.0.30226.2";
var actualVerArray =actualVer.split(".");
while ( actualVerArray.length > 3)

When I test the page in firefox I am prompted to download silverlight. The code works fine in IE 8 via activex - how should I modify the silverlight.js file created by Expression Web 3. If this is not the issue I am lost
9/11/2009 12:56 PM | # re: Updating Silverlight.js and Firefox 3
Expression Web 3 - Silverlight Video - Firefox 3.5
Tim helped! The object data code generated by Expression Web 3 when inserting a SL Video is missing a comma

Expression web Output the page code as:

<object data="data:application/x-silverlight-2" type="application/x-silverlight-2" width="720" height="480">

Thanks to Tim's Advice - Inserting the comma after the first 2 makes it work as:
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="720" height="480">

It now works in FireFox - Thank you Tim!
2/3/2010 2:41 PM | # re: Updating Silverlight.js and Firefox 3
Is this file...

C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Tools\Silverlight.js

...the same as this file...

C:\Program Files\Microsoft SDKs\Silverlight\v3.0\Tools\Silverlight.js


I only have the Silverlight 3 SDK installed so I do not the "v2.0" folder at all.

Can I simply use the file...

C:\Program Files\Microsoft SDKs\Silverlight\v3.0\Tools\Silverlight.js


2/3/2010 2:50 PM | # re: Updating Silverlight.js and Firefox 3
BTW, using this file...

C:\Program Files\Microsoft SDKs\Silverlight\v3.0\Tools\Silverlight.js

...does not seem to work.


Now I will install Silverlight SDK 2.0 and see if its "Silverlight.js" file works???
2/4/2010 11:21 AM | # re: Updating Silverlight.js and Firefox 3
Tim (and all) -- FYI, I was trying to solve the "SL 3 does not display in FF5 issue"; but, as it turns out, it was NOT the "Silverlight.js" file-- rather, it was the boilerplate code generated by VS.NET 2005 for the "Default.aspx" that hosts a Siverlight Application, where the bounding DIV tag needs to have style="height: 100%" in order to have it run. Not a fun fix but an easy one. Thank you for your help. -- Mark Kamoski

Please add 4 and 1 and type the answer here:


The opinions/content expressed on this blog are provided "ASIS" with no warranties and are my own personal opinions/content (unless otherwise noted) and do not represent my employer's view in any way.