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

Håkan Magnusson hakan at backbase.com
Wed Mar 31 02:59:12 CST 2004


In JavaScript, alert() is a method on the window object ("actual" syntax 
would be window.alert(sString);). A note to those of you who like to 
alert some value while you debug your code is that this method can 
naturally be replaced by your own function.

Remember every time you mistakenly put the alert in some loop and you 
have to sit on your return key for twenty minutes to get passed it? 
Well, by using this function, every alert is a confirmation dialog, and 
if you don't want to see any more alerts, simply click "Cancel" instead 
of "Ok".

---
function _alert(sAlert) {
	if(window.bAlert)
		window.bAlert = confirm(sAlert);
}
window.alert = _alert;
window.bAlert = true;
---

Just another of my two cents.

Regards,
H


Peter Brunone wrote:

>    IIRC, alert() is actually a method of the document object, and therefore language-independent.
> 
>    MsgBox is a bit more flexible, and works inside and outside of the browser environment.
> 
> Original Message:
> 
>>From: "Chris T" <christ at saeweb.com>
> 
> 
>>Hmmm, I thought VBScript was MsgBox(), not alert().
>>
>>Quick question... How many of you actually use VBScript? I'm talking
>>client-side, not server-side.
>>
>>Chris Tifer
>>
>>
>>
>>----- 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>
>>
>>_______________________________________________
>>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