Eval function execution leads to internal error

2019-07-09 08:47发布

问题:

I am doing analysis of our application with IE Edge browser, while doing so I found a strange behaviour. Execution of eval function leads to the below error. Even tried sample one like:

eval("2");

Error: SCRIPT51: Internal error

Please help me overcome this problem, in other browsers I am not facing this issue.

回答1:

I'm afraid that this seems to be a browser issue of IE Edge. You can't do anything to work around this issue except of getting rid of all your eval calls.

Since your application uses many eval functions (which is a bad idea), getting rid of them might be not an option. You'll have to wait until Microsoft fixes it's browser.

However, as eval is still used by many webpages, I'm sure that the bug will get a high priority and might be fixed before official release.



回答2:

Seems to be I found the root cause, the below trick solves my problem.

eval function needs to be specifically called with window context (though actually not requires)

Edge browser seems to be having some issue with context during evaluation.