Retrieve a Functional Reference Using GetRef in VBScript

Retrieve a Functional Reference Using GetRef in VBScript

Browsers Targeted: Internet Explorer 4+

One of the capabilities that JavaScript has long had that VBScript hasn’t supported is being able to associate an event handler with a specific function. For example, if you define an initialization routine that is fired when the document loads, attaching it to the window object involves simply passing the functional reference to that function:


You simply couldn’t do this in VBScript, which has limited its appeal considerably for client-side scripting. However, with Visual Basic 5 (released with later versions of Internet Explorer 4), you can use the GetRef() function to retrieve a functional reference to a given function. The previous JavaScript code would then look like this in VBScript:


In this case, the functional reference is passed as a string containing the name of the function.


Share the Post: