Notes from Daily Encounters with Technology RSS 2.0
 
# Sunday, October 29, 2006

Since gadgets are HTML applications and the Windows Sidebar uses Internet Explorer 7 to render them, I prefer running their code directly in IE7 during development. It makes debugging easier and allows me to develop them in Windows XP on my primary development machine with all the tools properly setup.

While this works great in early development stages, it becomes a problem later on when you start using the Windows Sidebar object model (to implement settings, visibility changes handlers etc.). This specific code understandably can only be debugged while running in Windows Sidebar but the unfortunate side effect is that the calls to objects which don’t exist in IE7 break the scripts and effectively prevent running the would-be gadget in IE7 even without this functionality.

The following function can help you keep the gadget running directly in IE7 even after the gadget specific functionalities are already implemented:

function isGadget()
{
    try
    {
        var dummy = System;
        return true;
    }
    catch (err)
    {
        return false;
    }
}

Just check if the application is running in Windows Sidebar at gadget startup and make sure to use the object model only when this is true. You can also add alternative initialization for running directly in IE7 to provide default values for settings and any other gadget specific variables. By doing this you can still test new features directly in IE7 if they are not gadget specific.

Sunday, October 29, 2006 2:11:59 PM (Central European Standard Time, UTC+01:00)  #    Comments [0] - Trackback
Development | Vista | Web
Sponsored Ads

About Me

Microsoft Certified Professional

Microsoft Certified Professional

View Damir Arh's profile on LinkedIn

Profile for ExAmigan

ExAmigan

Twitter
Snow pushed wild animals down from the hills again. Just saw a roe deer couple in a garden at the edge of the town while walking the dog. 18 hours ago
I finished the redesign of http://www.damirscorner.com - now it's time to write some new content. 11 days ago
Firebug is great. It helped me solve a CSS problem within minutes. http://getfirebug.com/ 11 days ago
Enjoyed watching Coraline. Would love to get my hands on a scottish terrier puppet from the movie. http://digs.by/1ZsY 11 days ago
@DanijelMalik I guess it depends on the project you are deleting. 13 days ago
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

All Content © 2010, Damir Arh, M. Sc. Send mail to the author(s) - Privacy Policy - Sign In
Based on DasBlog theme 'Business' created by Christoph De Baene (delarou)