javascript - 让文件://access http://localhost

标签 javascript .htaccess google-chrome

我有 2 个文件:桌面上的 file.html 和本地主机上的 local.html 。是否可以让文件访问本地主机?目前,我在 Chrome 上遇到此错误:

Uncaught SecurityError: Blocked a frame with origin "null" from accessing a frame with origin "http://localhost". The frame requesting access has a protocol of "file", the frame being accessed has a protocol of "http". Protocols must match.

首选 .htaccess 解决方案,但 Header set Access-Control-Allow-Origin * 不起作用。

最佳答案

你不能这么做。 (除非使用 JSONP 完全绕过策略)

您应该完全避免 file://

关于javascript - 让文件://access http://localhost,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34996836/

相关文章:

javascript - 无法让 Bootstrap 插件工作

php - .htaccess 错误文档重定向

服务器上的图像 URL 路径未在正常窗口中呈现,但在隐身模式中呈现

apache - (还有另一种)通过.htaccess中的重写方式删除www的漂亮方法吗?

php - .htaccess 使用 php $_GET 缩短 URL

sharepoint - 在 Mac 机器上使用 Google Chrome 和 FireFox 访问 SharePoint 内网

javascript - 为什么 Chrome 将数据 URL 评为交叉来源?

javascript - 如果对象值在javascript中为真,则迭代数组提取并添加到新列表

javascript - 如何在 JavaScript 中使用 XMLHttpRequest 设置 Cookie( header )?

javascript - HTML Purifier 用于清理事件属性