devxlogo

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.

See also  Does It Make Sense to Splurge on a Laptop?
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist