Jim Rogers

Lives in Baton Rouge, LA, with two dogs, one cat, and one lovely wife. I'm a lead developer for GCR Incorporated.

Katrin and Jim

Month List

Sidebar Gadget Context

by Jim Jan 28, 2010 9:05 AM

I’m writing a sidebar gadget, and using a standard browser window for most of my debugging. But of course the System object is not defined in this context, and I don’t want to constantly get error messages for this.

This function will check whether the script is running in the context of the sidebar, or in a regular browser:

// Check whether we're in a gadget 
// Returns false if loading in a regular browser.
function inGadgetContext() {
    return (typeof(window["System"]) == "undefined") ? false : true;
}

Tags:

Code