Using ObjectSwap To Avoid Flash/IE Activation Problems

Recently Microsoft lost a lawsuit which required that they not “automatically” enable dynamic content in their browser, or something.

Whatever.  The result is that you now have to CLICK on flash swf files running in your browser before they will be “Activated”.

The way to get around this is to use javascript to do the dirty work. 

Check out this link for a quick include that can help with the work around:

http://www.sitepoint.com/article/activex-activation-issue-ie

 

SmartNavigation with Metabuilders Combobox

I ran into a little problem trying to integrate Metabuilders combobox into an asp.net web app I am creating.

The problem was that the onload event handler was not properly firing when smartNav was turned on.

The “InitScript” was as follows:

if ( typeof( window.addEventListener ) != "undefined" ) {
    window.addEventListener("load", ComboBox_Init, false);
    alert('case 1');
} else if ( typeof( window.attachEvent ) != "undefined" ) {
    window.attachEvent("onload", ComboBox_Init);
} else {
    ComboBox_Init();

}

Well when you are using smartNav, the window.onload event is only fired the first time you reach the page.  So I used this bit of C# in the control to get it to work.

String initScript = resources.GetString("InitScript");
if (this.Page.SmartNavigation)
{
this.Page.RegisterStartupScript("MetaBuilders.WebControls.ComboBox Init with Smartnav", "<script>ComboBox_Init();</script>");
}
else
{
this.Page.RegisterStartupScript("MetaBuilders.WebControls.ComboBox Init", initScript);
}

 

Checking for JavaScript Variable Definitions

In some cases you need to be able to check if a variable has been defined, and if it has a value.

I recently had a problem where I needed a function to check if a variable had been defined, and if not, to return a default value “1”.

The following code will check if the variable is defined, and if it is, it will also check and make sure that it isn’t null, before returning the value.

 

function GetDefaultModuleId(){
    if (typeof(csDefaultModule) == "undefined"){                            
        return "1";
    }else{
        if (csDefaultModule == null){
            return "1";
        }else{
            return csDefaultModule;
        }                    
    }
}