I was creating a form validator for a client and ran into this weird error ONLY in Internet Exploder (Explorer) 7/8....
'return' outside of function, line 1, char 1
Of course, there was no code whasoever on line 1, it was a simple commented statement. And there was nothing wring with it in any way. So I knew it was just a debug miss-direct.
I have been pulling my hair out to understand what could be wrong here...
I have already ruled out the obvious: return statements in a loop, too many return statements in a single function, any returns actually outside of a legitimate function definition.
Has anybody else had any instances when this has happened to you?
I got it!
The problem was that I was using a return statement to override the default behavior for my form and it was assigned to a property, BUT it was not placed inside an anonymous function!
I had a form element that was set up like this:
All I needed to change was the action property to this:
It now works flawlessly!
Hope this saves someone else from the hell I went through.
I was getting this error with a ModalPopupExtender. I had specified the following attribute: OnOkScript="return false;"
Setting OkOkScript="" solve this issue for me.
©2020 All rights reserved.