当iFrame从本地html文件加载本地html文件时,Chrome的未来版本是否可以支持contentWindow / contentDocument? [英] Is it likely that future releases of Chrome support contentWindow/contentDocument when iFrame loads a local html file from local html file?

查看:555
本文介绍了当iFrame从本地html文件加载本地html文件时,Chrome的未来版本是否可以支持contentWindow / contentDocument?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Chrome中加载iFrame(frame.src =)中的另一个本地html文件时,我无法通过contentWindow或contentDocument访问其文档(即使使用contentWindow作为文档本身),因为它似乎当涉及本地html文件时,Chrome不允许。 Chrome的下一个版本可能会改变这个功能?注意:它与Safari和Opera,IE,WebKit一起工作(contentDocument或contentWindow)。这似乎是一个安全问题,但是ContentDocument和contentWindow来自W3C。

When I make a local html load another local html file in a iFrame (frame.src=) in Chrome, I cannot access its document through contentWindow or contentDocument (even with the verification of contentWindow being the document itself) because it seems Chrome doesn't allow it when a local html file is involved. Is it possible that this feature will change in next releases of Chrome? Note: it works (contentDocument or contentWindow) with Safari and Opera, IE, WebKit. It seems to be a security issue but contentDocument and contentWindow are from W3C.

推荐答案

这是因为Chrome限制被称为Same-原产地政策。默认情况下,本地文件被认为属于不同的来源,不允许从另一个访问。要解决此问题,您可以使用 - allow-file-access-from-files 命令行开关启动Chrome应用程序。

It is because of Chrome restriction known as Same-Origin Policy. By default the local files are considered to belong to different origins and not allowed to access one from another. To solve the issue, you can launch the Chrome application with the --allow-file-access-from-files command-line switch.

这篇关于当iFrame从本地html文件加载本地html文件时,Chrome的未来版本是否可以支持contentWindow / contentDocument?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆