Home > Web Front-end > JS Tutorial > Causes and solutions of 'Cannot execute released Script code' error_javascript skills

Causes and solutions of 'Cannot execute released Script code' error_javascript skills

WBOY
Release: 2016-05-16 19:09:09
Original
1109 people have browsed it

Many web developers may have encountered such a problem. The program inexplicably appears "Cannot execute the code of the released script", error line 1, column 1. The description of this kind of message is unclear, and the row and column description is even more confusing. 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 (function pointer) is passed to page a through js and saved in a variable of page a. Page a You can use this reference to operate page b or execute some programs on page b. Remember: at this time, the variable in page a saves the pointer (memory address) of a function on page b. When page b is refreshed or redirected, due to b The page is rebuilt, so the function pointer in page b has changed, but a still holds the pointer (memory address) passed before page b was refreshed. At this time, the variables in page a cannot be accessed through the pointer address pointed to. The corresponding function in page b (because the function pointer address has changed and the original memory pointer has been released), then the error "cannot execute the released Script code" will occur during execution.

Solution: Add fault tolerance processing to page a. When a reference error occurs, the saved reference (function pointer) should be cleared or pointed 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. First test, then return url, and then test again and this problem will occur.

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template