获取访问属性“文档”的权限被拒绝
Getting Permission denied to access property "document"
我不清楚为什么从不同域在 Web 浏览器中加载 HTML 文件时会出现此错误,I have not set any X-Frame-Options header in the HTTP response
访问属性"文档"的权限被拒绝
这是我的服务器头信息
curl -I zariga.com
输出
HTTP/1.1 200 OK
Date: Wed, 13 Jul 2016 17:17:57 GMT
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Set-Cookie: JSESSIONID=656D65705C14A5B643B6EA281DF03A8D; Path=/
Vary: Accept-Encoding
我的 HTML iFrame 文件
<html>
<script>
function myFunction() {
document.domain = "zariga.com";
var i = document.createElement('iframe');
i.setAttribute('id', 'i');
i.setAttribute('style', 'visibility:hidden;width:0px;height:0px;');
i.setAttribute('src', 'http://www.zariga.com/');
i.onload = function(){
alert(i.contentWindow.document.getElementsByName('syc')[0].value);
alert(2);
};
document.body.appendChild(i);
}
</script>
<body>
<button onclick="myFunction()">Try it</button>
</body>
</html>
您无法以这种方式访问 iframe 的内容。否则,您可以轻松地注入其他网站并窃取访问者的帐户。
如果您有权访问iframe中包含的网站,则可以让它向要包含的页面发送消息.iframe中的window.parent等同于主页中的窗口。
因此,要发回一个值,请将以下代码添加到主页:
function childCallback(value) {
}
这个到iframe中的页面:
parent.childCallback(document.getElementsByName('syc')[0].value);
相关文章:
- 在流星上使用微信js-sdk时出现拒绝权限错误
- 在Nodejs中Express输入DEBUG=app时权限被拒绝/bin
- Web 驱动程序管理器更新错误:EACCES,权限被拒绝
- 错误:在 Firefox 中访问 AJAX 请求的属性“nodeType”的权限被拒绝
- 解析主机时,可移植的本机客户端权限被拒绝
- Node.js bash:/usr/local/bin/Node:权限被拒绝
- 通知权限被拒绝(桌面推送通知).通知弹出窗口不会't以镀铬显示
- 访问属性的权限被拒绝'filepicker_comm_iframe'
- IE8谷歌可视化权限被拒绝
- CanvasJS-访问变量-访问属性toString的权限被拒绝
- 错误:访问属性“”的权限被拒绝;文件”;
- 权限被拒绝,forever.js为bash脚本
- opener.reload时拒绝了Javascript权限
- 错误-权限被拒绝-jQuery打印预览
- OAuth 2.0使用Google Client for JavaScript,获取权限被拒绝
- 尝试单击网页按钮,得到“错误 70 权限被拒绝”
- 使用XDomainRequest调用跨域AJAX时出现权限拒绝错误
- 1.9.1权限拒绝
- 如何在Firebase中使用js web API捕获读取权限拒绝
- 如何解决'权限拒绝访问属性'警报'