Results 1 to 4 of 4

Thread: 'return' Statement Outside of Function?? Help

  1. #1
    Join Date
    Jan 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 'return' Statement Outside of Function?? Help

    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/Authori...view=slogin.vm


  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    This looks to be the problem:

    Code:
            <!--function loadPage()
            {
                history.go(+1);
                focus('userid');
                return true;
            }-->
    Get rid of the red parts.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Jan 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •