<script type='text/javascript'>
function Go(){return}
</script>
<!-- this line leave an error !-->
<IMG alt="" src="images/SMALL_ABUZ_RECORDS.JPG" align="middle" />
<script type='text/javascript' src='scripts/exmplmenu_var.js'></script>
<script type='text/javascript' src='scripts/menu_com.js'></script>
This should work.
You either deleted more than just that line or your js files contain
code, that's based on the image's existence.
Without seeing that code (give a URL) one can only guess.
Daniel
> Hi I couldn't understand why in my web page when I've an image the page work
> and when I delete the image the code doesn't work anymore :
>
> <script type='text/javascript'>
> function Go(){return}
> </script>
> <!-- this line leave an error !-->
Yes, as it should.
function Go() {return true}
or
function Go() {return false}
When you use return, you have to return something. Not just return.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
This might be good style but it's not necessary. If you use return only,
the returned value is undefined but it's still a valid script.
Daniel
Not according to ECMA-262v3, 12.9:
ReturnStatement :
return [no LineTerminator here] Expression(opt);
Semantics
An ECMAScript program is considered syntactically incorrect
if it contains a return statement that is not within a
FunctionBody. A return statement causes a function to cease
execution and return a value to the caller. If Expression is
omitted, the return value is undefined. Otherwise, the
return value is the value of Expression.
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
I guess it depends on what you define as a "valid" script. :-)
If you aren't going to return anything, no need to return at all.
Well, if you don't have to return anything but have to return before
reaching the method's end, using just return might be good practice:
function foo(arg) {
if (!arg) return;
// do something();
}
This way, the method will always return undefined.
Of course, you could also write
function foo(arg) {
if (arg) {
// do something();
}
}
But this often makes a script less readable, especially if used with
more if statements.
Daniel