Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
220 views
in Technique[技术] by (71.8m points)

javascript - 如何在“--allow-file-access-from-files”模式下使用Chrome启动html?(How to launch html using Chrome at “--allow-file-access-from-files” mode?)

I have the same situation with HERE

(我和HERE的情况相同)

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

(要解决这个问题,我必须在“--allow-file-access-from-files”模式下使用Chrome启动html文件。)

I tried next steps many times, but it doesn't work.

(我多次尝试后续步骤,但它不起作用。)

  1. start cmd under windows 7

    (在Windows 7下启动cmd)

  2. direct to chrome.exe folder

    (直接到chrome.exe文件夹)

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

    (做这个chrome --allow-file-access-from-files file:///C:/test%20-%203.html)

  ask by AmyWuGo translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

That flag is dangerous!!

(那面旗子很危险!!)

Leaves your file system open for access.

(使文件系统保持打开状态以便访问。)

Documents originating from anywhere, local or web, should not, by default, have any access to local file:/// resources.

(默认情况下,源自任何地方,本地或Web的文档不应具有对本地file:///资源的任何访问权限。)

Much better solution is to run a little http server locally.

(更好的解决方案是在本地运行一个小的http服务器。)

--- For Windows ---

(---对于Windows ---)

The easiest is to install http-server globally using node's package manager:

(最简单的方法是使用node的包管理器全局安装http-server:)

npm install -g http-server

Then simply run http-server in any of your project directories:

(然后只需在任何项目目录中运行http-server :)

Eg.

(例如。)

d:\my_project> http-server
Starting up http-server, serving ./
Available on:
 http:169.254.116.232:8080
 http:192.168.88.1:8080
 http:192.168.0.7:8080
 http:127.0.0.1:8080
Hit CTRL-C to stop the server

Or as prusswan suggested, you can also install Python under windows, and follow the instructions below.

(或者如prusswan建议的那样,您也可以在Windows下安装Python,并按照以下说明操作。)

--- For Linux ---

(---对于Linux ---)

Since Python is usually available in most linux distributions, just run python -m SimpleHTTPServer in your project directory, and you can load your page on http://localhost:8000

(由于Python通常在大多数Linux发行版中都可用,只需在项目目录中运行python -m SimpleHTTPServer ,然后就可以在http://localhost:8000上加载页面了。)

In Python 3 the SimpleHTTPServer module has been merged into http.server , so the new command is python3 -m http.server .

(在Python 3中, SimpleHTTPServer模块已合并到http.server ,因此新命令是python3 -m http.server 。)

Easy, and no security risk of accidentally leaving your browser open vulnerable.

(简单,没有安全风险,意外地让您的浏览器易受攻击。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...