D'Arcy from Winnipeg
Solution Architecture, Business & Entrepreneurship, Microsoft, and Adoption

My Silverlight App Was Fine Until Chrome Came To Town

Sunday, January 10, 2010 9:29 PM


I put the final touches on a small Silverlight app that I had been working on over the weekend, and was doing some final testing of it. The app is pretty simple: it just displays stuff and has some buttons that take you to other web pages, launches the local email client, or downloads documents from a website. Simple tasks.

I ran into a weird issue which I’m pretty sure is Word 2010 related (not the focus of this post, more on that another time). I asked a buddy of mine to access the SL app on my webserver and try it out on his environment (he didn’t have Office 2010 beta installed).

Him: It doesn’t do anything

Me: What do you mean it doesn’t do anything?

Him: When I click the link to download the file, it doesn’t do anything.

Me: …

Him: I’m using Chrome though…I’ll try it in IE

So the IE on his side worked, hurray…but WTF was with the Chrome?! I had to investigate this for myself. Sure enough, Chrome rendered my app useless: none of the buttons or links worked.

The culprit was a combination of how I was trying to launch the different pages/docs and Chrome. Using the HtmlPage.Window.Navigate method works fine in IE and Firefox. However, it doesn’t work in Chrome…nadda…nothing…not even an error or anything, it just doesn’t react. THIS IS DUMB, mainly because of what the options are for ensuring this functionality will work in chrome:

Option 1 – Write a JavaScript method in the containing page, and have Silverlight just call out to that to execute the external URIs. Doable, but BLECH.

Option 2 – Instead of HtmlPage.Window.Navigate, use HtmlPage.Window.Eval. Eval basically let’s you pass in JavaScript for the containing HTML page to evaluate and execute…so its pretty much the same thing as Option 1 above, just in a different format.

I did Option 2, passing in a window.open parameter complete with the uri I wanted to navigate to…I basically had to write the JavaScript inside my code. Not ideal, but for the scope of my application I was ok with it.

So if your Silverlight app is going to be publically available, make sure that you include Chrome in with your testing. Yes, you should be testing in all browsers anyway, but sometimes we might assume simple functionality will just work across all three. That is *not* the case.




Feedback

No comments posted yet.


Post a comment