如何根据位置检测是否获得了正确的iframe,但是却获得了iframe的元素,而不是iframe本身? (如果说得通)
在我的iframe(B)中,我调用以下函数以获取iframe A
findFrameA(): any {
console.info('Core::findFrameA()', parent.frames.length + ' frames found')
// Start with the last one as it should "normally" be near the end
for(var i = parent.frames.length - 1, t = 0; i>=t; i--) {
let thisFrame = parent.frames[i]
let thisFrameUrl = thisFrame.location
let frameOrigin = thisFrameUrl.origin
let framePath = thisFrameUrl.pathname
console.log()
if(frameOrigin === Config.remoteDomain && framePath === '/framea') {
console.info('Core::findFrameA()', thisFrame)
return thisFrame;
}
}
}
现在,我想访问iframe A(一个div)的父级,但是this.findFrameA()返回该帧的Window元素。
<div> <--- Get this element
<iframe src="frameB"/>
<iframe src="frameA"/>
</div>