Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic, Web
Expertise: Intermediate
Feb 3, 2000

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:

 
<script language="JavaScript">
	function Initialize(){
		// Put some initialization code here
		}
		
	window.onload=Initialize; 
// Functional reference has no parentheses.
</script>

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:

 
<script language="VBScript">
	function Initialize()
		// Put some initialization code here
	end function
	
	window.onload=GetRef("Initialize") 
</script>

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

Kurt Cagle
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap