Javascript 我只想在Iframe中加载(实时)源url的主体

Javascript 我只想在Iframe中加载(实时)源url的主体,javascript,html,css,iframe,Javascript,Html,Css,Iframe,我正在Iframe中完成源URL的loadonly body标记的任务。除此之外没有别的。 我已经为它完成了以下代码。 一个javascript函数 Function test(){ var iframe=document.getElementById('test'); iframe.contentWindow.document.body.style.backgroundColor="green"; } <iframe id="Iframe1" width="700" height="4

我正在Iframe中完成源URL的loadonly body标记的任务。除此之外没有别的。 我已经为它完成了以下代码。 一个javascript函数

Function test(){
var iframe=document.getElementById('test');
iframe.contentWindow.document.body.style.backgroundColor="green";
}

<iframe id="Iframe1" width="700" height="400" src="http://www.facebook.com" Onload=test()></iframe>
功能测试(){
var iframe=document.getElementById('test');
iframe.contentWindow.document.body.style.backgroundColor=“绿色”;
}
但没有效果

我的实际任务是仅将自定义css应用于该body标记


请建议任何解决方案。

除非您在浏览器设置中明确关闭跨域脚本保护,否则这将不起作用。你可以试试你的写作运气。

政府不会让你这么做的。好的。谢谢你的回复,但是还有其他方法吗。