[thelist] Javascript function

Aylard James J jaylard at equilon.com
Mon, 20 Dec 1999 10:58:16 -0600


Jeff,

> i've checked all of the vbscript references i can find, including
> microsoft's and i don't see any reference to using "javascript:" as the
> preface to a function call in an event handler.  the only thing i see is
> using the language attribute.

	Yes, this is *very* poorly documented. In fact, the only place that
I know of offhand where it is documented is the book "Inside Dynamic HTML"
by Scott Isaacs, p.64 in my copy (Chapter 3: Dynamic HTML Event Model,
"Specifying Scripting Languages in Event Attributes"). My guess is that the
language attribute is the "correct" way to specify the language for a given
tag, and that including the language-identifier in the event attribute is a
hackish shortcut, although specifying it in the event attribute does offer
the advantage of using different languages for different events on the same
tag.

> in fact, you have to use a language attribute
> to send a function call to vbscript, otherwise ie expects the function
> you're calling is javascript, even if vbscript is the first script block
in
> the document.

	Actually, that's not true. As long as VBScript is specified as the
default language for the page (by placing an identified VBScript script
block as the first script block on the page), you can call VBScript routines
without any language identifier in the event handler and without an inline
language attribute. However, I take back my earlier suggestion that you can
specify the default page language in the HTML tag. I had read that
somewhere, but have now tested it and find that it doesn't actually work.

> out anything for sure regarding this, but got the feeling 
> that if there was a specific function called and it didn't exist in the 
> javascript block then the browser would look for it in the vbscript block
if no
> language was specified, contradicting what webreference has to say about
it and

	In my experience, calling a function or sub in the *non-default*
language *without* specifying the language (either as part of the event
attribute or in the language attribute) will invariably throw an error. I
have never tried all of the ins and outs that WebReference mentions because
I always specify both a language and type attribute for all of my script
tags, whether for JavaScript or VBScript.
	In fact, this is actually an object-model issue far more than it is
a scripting issue. Having come through the IE door in this whole process, I
often turn black-and-blue trying to fathom the Netscape object model (and am
anxiously awaiting the standards-based approach of the final Mozilla
release). I am always impressed by someone who grasps and can readily
explain the Netscape object model's approach to scripting, as you clearly
can. It's a rough business, from my point of view! ;)

James Aylard
Equilon Enterprises LLC
jaylard@equilon.com