admin管理员组

文章数量:1395151

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);
        }()
    );

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);
        }()
    );
Share Improve this question edited May 14, 2016 at 6:26 rajthakur 4536 silver badges16 bronze badges asked May 14, 2016 at 5:59 Eddie Costa DominguesEddie Costa Domingues 351 gold badge1 silver badge6 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2

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.

Create a python server using

python3 -m http.server 8086

and replace the

file:///<PATH_TO_FILE>

with https://localhost:8086/<RELATIVE_PATH_TO_FILE>

本文标签: javascriptjs file not loading js console say39s quotNot allowed to load local resourcequotStack Overflow