Cannot open local file - Chrome: Not allowed to load local resource

后端 未结 14 1625
不知归路
不知归路 2020-11-22 12:01

Test browser: Version of Chrome: 52.0.2743.116

It is a simple javascript that is to open an image file from local like \'C:\\002.jpg\'

function run(         


        
14条回答
  •  一整个雨季
    2020-11-22 12:44

    Google Chrome does not allow to load local resources because of the security. Chrome need http url. Internet Explorer and Edge allows to load local resources, but Safari, Chrome, and Firefox doesn't allows to load local resources.

    Go to file location and start the Python Server from there.

    python -m SimpleHttpServer

    then put that url into function:

    function run(){
    var URL = "http://172.271.1.20:8000/" /* http://0.0.0.0:8000/ or http://127.0.0.1:8000/; */
    window.open(URL, null);
    }
    

提交回复
热议问题