Home >Web Front-end >JS Tutorial >Reasons and solutions for the error 'Cannot execute released Script code'_javascript skills

Reasons and solutions for the error 'Cannot execute released Script code'_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:09:241229browse

Many web developers may have encountered such a problem. The program strangely displays "Cannot execute the code of the released script", error line 1, column 1. The description of this message is unclear, and the column description is even more random js. Errors are believed to be the most depressing and hated thing for all friends who debug JS programs! When encountering this kind of problem, the easiest way is to directly paste the error into the small input box of Baidu or Google and let them give you some pointers before solving it. But this time it is not so easy. It seems that many people have encountered this problem when searching on Baidu. I've seen this kind of problem before, but it's always some kind of QQ space error, I'm crazy, or there are only questions but no answers, boring!

Where does this error come from? I had no choice but to guess and try...catch the error. After searching for a long time, I finally found the location of the error. However, I found that there was nothing wrong with the writing. Afterwards, I racked my brains to think about the explanation process of the program, but I still have no clue. . Continuing on Baidu, I suddenly saw a sentence in a certain web page: When a page is closed, the js of the page will be automatically released. This short sentence gave me a lot of inspiration. I checked whether my program closed or redirected the page, and found that the redirection was executed, and then an error occurred when returning to this page. Suddenly I understood.

Scenario: The page has two frame pages iframe a and b. In page b, a function reference is passed to page a through js and saved in a variable of page a. Page a can be executed through this reference For some programs on page b, when page b is refreshed, the reference from page a to page b has been lost, but the reference passed from page b before is still saved in a, but the current reference can no longer refer to page b, so when executing "The released Script code cannot be executed" will appear.

Solution: Add fault tolerance processing to the a page. When an error occurs in the reference, clear the reference or point it to a default function. In addition, when page b is loaded again, the function reference must be transferred to page a again, so that such an error will not occur.

Perhaps the description here is a bit too abstract. It will be easy to understand after watching a demonstration and then looking at the code. Test first, then return the url, and then test again and this problem will occur.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn