Script error error how to solve the problem

If the script URL with the URL of the page is not in the same domain (such as using a CDN), that if the script execution error, it will report: Script error. 

Since the same-origin policy, the browser prohibits leaking information to an external script, it does not provide complete error message, but reported a "Script error.", The line number is 0, no additional information.

 

One solution is to: in a server script is located, the HTTP header information provided Access-Control-Allow-Origin of, <script> tag set crossorigin property page.

Access-Control-Allow-Origin: *
<script crossorigin="anonymous" src="//example.com/file.js"></script>

 

Guess you like

Origin www.cnblogs.com/aisowe/p/11719054.html