Microsoft Most Valuable Professional

Chris Pietschmann

An MVP From Wisconsin



ASP.NET Atlas is full of JavaScript goodness

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

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: General
Posted by crpietschmann on Wednesday, June 21, 2006 9:00 AM
Permalink | Comments (1) | Post RSSRSS comment feed

Related posts

Comments

Jim

Wednesday, August 02, 2006 5:30 PM

Jim

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!

Comments are closed

About the author

I'm Chris Pietschmann, go to the About Me page to learn more about me.

Search

Sponsors

Web.Maps.VE - ASP.NET AJAX Virtual Earth Mapping Server Control

Recent comments

Disclaimer


This work is licensed under a Creative Commons Attribution 3.0 United States License, unless explicitly stated otherwise within the posted content.
© Copyright 2004 - 2008 Chris Pietschmann