js代码 获取iframe中的内容

我用userscript处理网站的数据的脚本遇到了一个问题。
我要处理的网页代码中有一个iframe标签,里面的内容来自于另一个网址

<iframe scr ="aaaa.html" id ="a"></iframe>

而我打开aaaa.html时,发现我要处理的数据在另一个iframe标签中

<iframe scr ="bbbb.html" id ="b"></iframe>

为了处理bbbb.html中的数据,我使用了以下的代码

var a = document.getElementById("a").contentWindow;
var b = a.document.getElementById("b").contentWindow;
var stats = b.document.getElementById("我要的数据id值").innerHTML;

但是并没有效果,求问问题出在哪里,有无什么方法可以获取嵌套iframe中的数据。

这样写试试 document.getElementById("a").contentWindow.test() 或者 document.frames["a"].test()

里面的内容来自于另一个网址,这是跨域的,浏览器不允许跨域操作

是呀,前端无法解决跨源的问题。