Home > Web Front-end > JS Tutorial > How to Safely Open Local HTML Files in Chrome?

How to Safely Open Local HTML Files in Chrome?

Patricia Arquette
Release: 2024-12-06 01:12:09
Original
138 people have browsed it

How to Safely Open Local HTML Files in Chrome?

How to Launch HTML Using Chrome in "--allow-file-access-from-files" Mode?

Navigating this issue necessitates launching the HTML file through Google Chrome in "--allow-file-access-from-files" mode. However, it has proven unsuccessful despite repeated attempts to implement the following steps:

  1. Launch the command prompt in Windows 7.
  2. Navigate to the chrome.exe folder.
  3. Input the command: chrome --allow-file-access-from-files file:///C:/test - 3.html

Addressing the Situation

The command proposed in the steps poses a significant security risk by granting unrestricted access to the local file system. A far more secure solution lies in setting up a local HTTP server.

For Windows Users

Install the http-server package globally using Node's package manager:

npm install -g http-server
Copy after login

To initiate the HTTP server within a specific project directory, simply execute:

Eg. d:\my_project> http-server
Copy after login

A message will appear, indicating the successfully running server.

Alternatively, Python can be installed on Windows to execute the following commands.

For Linux Users

As Python is generally included in Linux distributions, executing the following command in the project directory will suffice:

python -m SimpleHTTPServer
Copy after login

Your browser can then access the page via http://localhost:8000.

For Python 3, the command is modified to:

python3 -m http.server.
Copy after login

Adopting this approach eliminates potential security vulnerabilities while providing a simple solution to the underlying issue.

The above is the detailed content of How to Safely Open Local HTML Files in Chrome?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template