Declaring functions in JavaScript??

wxdqz

New Member
I recently ran into a problem in both Netscape 7.01 and Mozilla 1.2.1. When trying to call a JS function from within a function, the JS Debugger indicates that the function has not been declared.

Do you now have to declare functions as in C before using them? See the JS code snippet below. In Netscape 7.01, foobar() never gets called. Note: I placed periods "." in the tags below so that browsers would not think the code was HTML or JavaScript.

Would appreciate if anyone has encountered a similar problem, and if there is a work around. It seems to be a bug in the Netscape/Mozilla code.


<.html>
<.head>
<.script language = "JavaScript">
function foo(){
document.write("Hello, how are you?");
foobar();
}

function foobar(){
document.write("Just fine, thanks!");
}
<./script>
<./head>
<.body onLoad="foo()">
<./body>
<./html>
 
Back
Top