tags:

views:

169

answers:

3

So I've been looking at a blog post with some javascript in it and there is something I'm looking at which I don't quite follow:

function pageLoadedHandler(sender, args) {  
    if (typeof(lastFocusedControlId) !== "undefined" 
         && lastFocusedControlId != "")   
    {  
        var newFocused = $get(lastFocusedControlId);  
        if (newFocused) {    
            focusControl(newFocused);
        }
    }

In the above method it calls $get which i assume is an alias to

 function(id) { 
     return document.getElementById(id); 
 }

There is nowhere in the supplied js file where $get is declared.

Is this a reserved alias and can someone provide the link which provies it. If not how does it know what $get is?

+3  A: 

I believe you're looking at ASP.NET's AJAX shortcuts.

http://mattberseth.com/blog/2007/08/the_everuseful_get_and_find_as.html

Elliot Nelson
+1  A: 

The example you mention is based on ASP .NET, $find and $get are two "shortcut" functions provided by the MS Ajax Framework

CMS
A: 

Yes I've found them: Quoting Msdn

Sys.UI.DomElement $get Method

Provides a shortcut to the getElementById method of the Sys.UI.DomElement class. This member is static and can be invoked without creating an instance of the class.

http://www.asp.net/AJAX/Documentation/Live/ClientReference/Global/GetShortCutMethod.aspx

http://msdn.microsoft.com/en-us/library/bb397717.aspx

Very difficult to search for $get

John Nolan