Home > Web Front-end > JS Tutorial > body text

Why doesn't javascript have permission?

藏色散人
Release: 2021-06-18 11:17:29
Original
2372 people have browsed it

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.

Why doesn't javascript have permission?

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>
Copy after login

Running result:

Why doesnt javascript have permission?

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!

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!