[Javascript] Same-named functions (was link onclick=location.hrefnot working)

Peter Brunone peter at brunone.com
Tue Mar 30 12:23:53 CST 2004


   Oh, no, I wasn't trying to implicate you in any of this; I was just following up on Chris's "I wonder what would happen" statement (although he was correct that event handlers are not language-specific, and henceforth probably wouldn't ever require a pseudoprotocol in future standards).  The results, as outlined below, seemed worthy of comment.

Peter

Original Message:
>From: "David Lovering" <dlovering at gazos.com>

>You may recall that I did say "someday", and not "now"
>
>-- Dave Lovering
>
>----- Original Message ----- 
>From: "Peter Brunone" <peter at brunone.com>
>
>> > What I don't know
>> >is what would happen if you had 2 functions (one JS and one VB) by the
>same
>> >name. I'm too lazy to find out though :)
>>
>>   Never say "what if" around me; you'll get either the answer or endless
>speculation.  In this case, I put together a small sample for IE6, and the
>result was a trip to Bizarro World.  Consider the following:
>>
>> <form>
>> <input type="button" onclick="Gabooga()" value="Call VBScript Function">
>&nbsp;
>> <input type="button" onclick="gabooga()" value="Call Javascript Function">
>> <br>
>> </form>
>> <script language="Javascript">
>> function gabooga() {
>> alert("gabooga javascript");
>> }
>> </script>
>>
>> <script language="VBScript">
>> Function Gabooga
>>    alert("Gabooga VBScript")
>> End Function
>> </script>
>>
>>    If you run this in IE, you get the exact opposite of what you would
>expect (the one calling the VBScript function actually calls the Javascript
>function, which would seem to be an impossibility due to the case
>sensitivity of the language.  Commenting out the VBScript function takes
>things back to normal, and the JS-triggering button throws an error.
>Commenting out the JScript function allows both buttons to home in on the
>case-insensitive VBScript function.
>>
>>    Case both buttons' function calls the same (lower-case g) and you'll
>STILL see them call different functions.  Isn't MS error-tolerance fun?
>>
>> Cheers,
>>
>> Peter
>>
>> Original Message:
>> >From: "Chris T" <christ at saeweb.com>
>> >
>> >> Now if
>> >> folks start hanging VB script and other funky things off of event
>handlers
>> >> as a matter of regular course (and revised W3C standards), this might
>> >> someday change...
>> >
>> >VBScript works much in the same way, right? The event handler isn't
>> >neccessarily tied simply to JavaScript.
>> >
>> >Admittedly, I don't use VBScript all that much (if ever), so I may be
>> >mistaken, but an event is just that. It's not neccessarily a "JavaScript"
>> >event.  Scripting languages are interchanged easily enough to where you
>can
>> >call a JS function that in turn calls a VBScript function. What I don't
>know
>> >is what would happen if you had 2 functions (one JS and one VB) by the
>same
>> >name. I'm too lazy to find out though :)
>>
>>
>> _______________________________________________
>> Javascript mailing list
>> Javascript at LaTech.edu
>> https://lists.LaTech.edu/mailman/listinfo/javascript
>>
>>
>
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript
>
>





More information about the Javascript mailing list