3
我有3個嵌套iframe,我想要訪問第三個iframe中的元素(鏈接)。從其他iframe字符串獲取iframe元素
var iframe = document.getElementById('aswift_2');
var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
var secondIframe = innerDoc.getElementById('google_ads_frame3');
var secondinnerDoc = secondIframe.contentDocument || secondIframe.contentWindow.document;
var treedIframe = document.getElementById('ad_iframe');
var secondinnerDoc = treedIframe.contentDocument || treedIframe.contentWindow.document;
var Link = secondinnerDoc.getElementById('aw0');
但是我在嘗試訪問時出錯。
Uncaught DOMException: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "http://localhost:63342" from accessing a cross-origin frame.
我怎樣才能訪問<a>
標籤?