ASP.NET Atlas is full of JavaScript goodness

21. June 2006

I was looking through the JavaScript code for Atlas and I noticed there is some pretty neat stuff in there. It is really a very large enhancement to JavaScript.

One of the things I noticed is they are adding support for the XMLHttpRequest object if the browser doesn't natively support it. In the past I've traditionally just created a function named similarly to 'CreateXMLHttpRequestObject' and I make that function support multiple browsers. The technique that's used in Atlas is they are adding the 'window.XMLHttpRequest' object if it doesn't already exist. This allows for your AJAX code to support multiple browsers more easily by making it so you don't need to change your code to support Internet Explorer. And your code will still work in IE7 because IE7 natively supports the 'window.XMLHttpRequest' object. Very nice guys!

Below is the above mentioned chunk of JS code for your viewing pleasure:

//-----------------------------------------------------------------------
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------
// Atlas.js
// Atlas Framework.
//
if (!window.XMLHttpRequest) {
    window.XMLHttpRequest = function() {
        var progIDs = [ 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP' ];
    
        for (var i = 0; i < progIDs.length; i++) {
            try {
                var xmlHttp = new ActiveXObject(progIDs[i]);
                return xmlHttp;
            }
            catch (ex) {
            }
        }
    
        return null;
    }
}

 

Remember the above code is technically copyrighted to Microsoft and is part of the Atlas Framework.

ASP.NET Atlas Framwork

asp.net, JavaScript ,

Comments

Jim
Jim
8/2/2006 7:30:00 PM #
I've got a page with a javascript setTimeout/loop routine that I use to do a "custom" callback to see if particular events have occurred at the server.  When I add an updatepanel to the page, and execute a control within the updatepanel, it appears to stop the setTimeout loop...and I don't know how to restart it.  I could restart it with "any user event", however, I'd like most of those events to be within update panels, so that won't help.

Do you happen to know of a way that the update panel can fire a javascript function when it completes execution of the postbacks within it?

Any help on this would be appreciated.

Thanks!