How to launch html using Chrome at “--allow-file-access-from-files” mode?

前端 未结 11 1624
我寻月下人不归
我寻月下人不归 2020-11-21 23:12

I have the same situation with HERE

And to solve this problem I have to launch html file using Chrome at \"--allow-file-access-from-files\" mode. I tried next steps

相关标签:
11条回答
  • 2020-11-21 23:43

    Don't do this! You're opening your machine to attacks. Instead run a local server. It's as easy as opening a shell/terminal/commandline and typing

    cd path/to/files
    python -m SimpleHTTPServer
    

    Then pointing your browser to

    http://localhost:8000
    

    If you find it's too slow consider this solution

    0 讨论(0)
  • 2020-11-21 23:44

    You may want to try Web Server for Chrome, which serves web pages from a local folder using HTTP. It's simple to use and would avoid the flag, which, as someone mentioned above, might make your file system vulnerable.

    0 讨论(0)
  • 2020-11-21 23:51

    As of this writing, in OS X, it will usually look like this

    "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --allow-file-access-from-files
    

    If you are a freak like me, and put your apps in ~/Applications, then it will be

    "/Users/yougohere/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --allow-file-access-from-files
    

    If neither of those are working, then type chrome://version in your Chrome address bar, and it will tell you what "command line" invocation you should be using. Just add --allow-file-access-from-files to that.

    0 讨论(0)
  • 2020-11-21 23:54

    Well there is quick to run a html which needs permission or blocked by CORS Just simply open the folder using VSCODE and install an extension called "live server"

    And then just click on the bottom which says go live, thats it. Screenshot

    0 讨论(0)
  • 2020-11-21 23:54

    On windows:

    chrome --allow-file-access-from-files file:///C:/test%20-%203.html
    

    On linux:

    google-chrome --allow-file-access-from-files file:///C:/test%20-%203.html
    
    0 讨论(0)
  • 2020-11-21 23:56

    If you are using a mac you can use the following terminal command:

    open -a Google\ Chrome --args --allow-file-access-from-files
    
    0 讨论(0)
提交回复
热议问题