不安全的 JavaScript 尝试使用 URL 访问框架。它是本地的

发布于 2024-11-30 23:17:18 字数 424 浏览 7 评论 0原文

我正在使用phonegap 构建一个jQuery 移动应用程序。 当我尝试访问 iframe(可能是 webkit)中的页面时,存在不安全的 JavaScript 尝试访问框架的问题。框架页面和父页面都在本地,以 file:/// 开头。我知道这样的问题在哪里 不安全的 JavaScript 尝试访问 Google Chrome 中的框架但我无法传递 --allow-file-启动时从文件访问开关在我的手机上。而且我也不想在互联网上部署我的应用程序。还有其他选项可以解决此问题吗?最好不需要对浏览器做任何修改。谢谢。

I am building a jQuery mobile app with phonegap.
There is a issue of Unsafe JavaScript attempt to access frame when I tried to access a page in iframe (Maybe webkit). Both of the framed page and parent page are at local,which is start with file:///.I know where is a question like this Unsafe JavaScript attempt to access frame in Google Chrome But I cannot passing the --allow-file-access-from-files switch at startup on my phone.And I also don't want to deploy my app on internet.Is there any other option to solve this? It should be better that I don't need to do any modification on the browser.Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薄荷梦 2024-12-07 23:17:18

我不确定 Webkit 是否遵循相同的规则,但有先例。

https://developer.mozilla.org/en/Same-origin_policy_for_file%3a_URIs

在 Gecko 1.8 或更早版本中,任何两个 file: URI 都被视为
同源。换句话说,本地磁盘上的任何 HTML 文件都可以
读取本地磁盘上的任何其他文件。

从 Gecko 1.9 开始,文件只能读取某些其他内容
文件。具体来说,只有父文件才能读取另一个文件
原始文件的目录是该文件的祖先目录
目标文件。但是,目录不能以这种方式加载。

例如,如果您有一个文件 foo.html 可以访问另一个文件,
bar.html,仅当 bar.html 位于同一目录中时,加载才会成功
foo.html 目录或同一目录中包含的目录
目录为 foo.html。

此政策会影响任何进行同源检查的内容,包括
XMLHttpRequest、XSLT 和 XBL。

对于跨窗口 DOM 访问,每个文件都被视为一个单独的文件
origin,但有一个例外:如果一个文件是从另一个文件加载的
否则就能够按照同源策略加载它,
它们被认为具有相同的起源。这种负载可能会发生
通过子框架、链接、位置集、调用 window.open() 或
喜欢。

例如,如果文件 /home/user/foo.html 是一个框架集并且是以下之一
框架是/home/user/subdir/bar.html,框架和框架集是
被认为具有相同的起源。另一方面,如果文件
/home/user/subdir/foo.html 是一个框架集,框架是
/home/user/bar.html,框架和框架集被认为有
出身不同。

新的 security.fileuri.strict_origin_policy 首选项,
默认为 true,如果用户不想,可以设置为 false
对文件:URI 严格执行同源策略。

I'm not sure if Webkit follows the same rules, but there is a precedent.

https://developer.mozilla.org/en/Same-origin_policy_for_file%3a_URIs

In Gecko 1.8 or earlier, any two file: URIs are considered to be
same-origin. In other words, any HTML file on your local disk can
read any other file on your local disk.

Starting in Gecko 1.9, files are allowed to read only certain other
files. Specifically, a file can read another file only if the parent
directory of the originating file is an ancestor directory of the
target file. Directories cannot be loaded this way, however.

For example, if you have a file foo.html which accesses another file,
bar.html, the load will succeed only if bar.html is either in the same
directory as foo.html or in a directory contained within the same
directory as foo.html.

This policy affects anything that does same-origin checks, including
XMLHttpRequest, XSLT, and XBL.

For cross-window DOM access, each file is treated as a separate
origin, with one exception: if a file is loaded from another file that
would otherwise be able to load it following this same-origin policy,
they are considered to have the same origin. This load can occur
through a subframe, link, location set, call to window.open(), or the
like.

For example, if the file /home/user/foo.html is a frameset and one of
the frames is /home/user/subdir/bar.html, the frame and frameset are
considered to share the same origin. On the other hand, if the file
/home/user/subdir/foo.html is a frameset and the frame is
/home/user/bar.html, the frame and frameset are considered to have
different origins.

The new security.fileuri.strict_origin_policy preference, which
defaults to true, can be set to false if the user doesn't want to
strictly enforce the same origin policy on file: URIs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文