js文件不加载js控制台说的是“不允许加载本地资源” [英] js file not loading js console say's "Not allowed to load local resource"

查看:1763
本文介绍了js文件不加载js控制台说的是“不允许加载本地资源”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的 JavaScript 代码未在 JavaScript控制台中加载


不允许加载本地资源:


Javascript:

 (function(){
var script = document.createElement('script');
script.setAttribute('src ','file:///home/chronos/u-1dd073c6b7b8430c0010c7429b07db331325c324/Downloads/Core/tube.js');
document.body.appendChild(script);
}()
);


解决方案

但也许你会发现它很有用:



检查您的主机是否完全合格在这里



您也可以阅读指南 in here



一些浏览器,如现代版本的Chrome,甚至会拒绝从http协议转换为文件协议。 Chrome和Safari似乎使用了更为严格的沙箱实现(出于安全原因),而不是其他两种。

最后,您不应该从本地文件系统加载javascript文件。您需要将它与您的应用程序一起托管并从Web服务器上加载它。


The JavaScript code below is not loading, in the JavaScript console it says,

"Not allowed to load local resource:"

Javascript:

    (function () { 
        var script = document.createElement('script'); 
        script.setAttribute('src','file:///home/chronos/u-1dd073c6b7b8430c0010c7429b07db331325c324/Downloads/Core/tube.js'); 
        document.body.appendChild(script);
        }()
    );

解决方案

This stuff is mostly pasted from other questions but perhaps you will find it useful:

Check if your host is fully qualified in here

You can also read a guide in here

Some browsers, like modern versions of Chrome, will even refuse to cross from the http protocol to the file protocol. Chrome and Safari seem to use a more strict implementation of sandboxing (for security reasons) than the other two.

Finally, you shouldn't load javascript files off a local filesystem. You need to have it hosted with your app and load it off the web server.

这篇关于js文件不加载js控制台说的是“不允许加载本地资源”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆