PDA

View Full Version : 'return' Statement Outside of Function?? Help



StingRay327
01-30-2007, 10:46 PM
I'm new to javascript and am getting an error "'return' statement outside of function" Line 79 Char 13"

I go to that line in my code and am not seeing the problem. I must be over looking something simple. If someone can view source on my page and let me know that they think that'd be great!!! Thanks

My page with the problem is:
https://mfa.lanxtra.com/auth/Authorize?fiid=323173313&view=slogin.vm

:confused:

jscheuer1
01-30-2007, 10:58 PM
This is a function (they can look various ways but, most are something like so:

function doSomething(){
stuff to do here
}

You cannot use:

return

outside one of those. For example, some regular code outside of a function:

var blah=10
var bleh=1
if(blah>bleh)
return //<--can't do this.

You can only return from a function. If it is nested, you return to the parent function. If it isn't nested, you return to the global object. If you are already at the global object, there is nowhere to return to.

jscheuer1
01-30-2007, 11:00 PM
This looks to be the problem:


<!--function loadPage()
{
history.go(+1);
focus('userid');
return true;
}-->

Get rid of the red parts.

StingRay327
01-30-2007, 11:24 PM
Thanks for your help John. I had a feeling that part didn't look right but didn't know for sure. I'll try it now. Thanks again.