The reasons why javascript does not have permission: 1. Due to logic errors, such as closing the iframe first, and then calling the function in the main page; 2. Because the sub-page is cross-domain, you need to carefully check the src of the iframe address.
The operating environment of this article: windows7 system, javascript version 1.8.5, Dell G3 computer.
Why doesn’t javascript have permission?
javascript runtime error: no permission reason:
There are two reasons:
1. It is a logical error, such as closing the iframe first and then calling the homepage function in the surface.
2. The subpage is cross-domain, please carefully check the src address of the iframe.
JavaScript Error
The Error object provides error information when an error occurs.
In the following example, the try statement block contains the undefined function "adddlert". Executing it will generate an error, and the catch statement block will output the error message:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML中文网</title> </head> <body> <h2>JavaScript Error 对象</h2> <p>以下实例中 try 语句块包含了未定义的函数 "adddlert" ,执行它会产生错误,catch 语句块会输出该错误的信息。</p> <p id="demo" style="color:red"></p> <script> try { adddlert("Welcome guest!"); } catch(err) { document.getElementById("demo").innerHTML = err.name + "<br>" + err.message; } </script> </body> </html>
Running result:
Recommended study: "javascript advanced tutorial"
The above is the detailed content of Why doesn't javascript have permission?. For more information, please follow other related articles on the PHP Chinese website!