如何将属性值从 iframe 传递给父级?
即iframe (frame1) 有 <a id="a1" href="http://www.infinitybusiness.net">
.如何获得 href
的值(value)在我的父页面中?
最佳答案
var fra = document.getElementById('frameId');
// following will work on same domain (or subdomain with document.domain set) only
var fraContent = fra.contentDocument || fra.contentWindow.document;
myLinkHref = fraContent.getElementById('myLinkId').href;
如果这是跨域的,那么您将需要有权将脚本添加到子框架。如果没有,则没有服务器端代理就无法完成。
关于javascript - 如何从 Javascript 中的父级获取 iframe 内的属性值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3381920/