【发布时间】:2015-05-11 06:29:39
【问题描述】:
我想自定义 Facebook 提要的设计,为此我想在 Facebook iframe 中添加自定义样式表。
我有什么
<iframe width="1000px" height="1000px" frameborder="0" name="f1e348592ed856c" allowtransparency="true" allowfullscreen="true" scrolling="no" title="fb:page Facebook Social Plugin" style="border: medium none; visibility: visible; width: 340px; height: 500px;" src="http://www.facebook.com/v2.3/plugins/page.php?app_id=&channel=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter%2FKTWTb9MY5lw.js%3Fversion%3D41%23cb%3Df46f9e2a3b7b8%26domain%3D10.0.0.101%26origin%3Dhttp%253A%252F%252F10.0.0.101%252Ff24c367e49e04c%26relation%3Dparent.parent&container_width=1584&hide_cover=false&href=https%3A%2F%2Fwww.facebook.com%2Ffacebook&locale=en_US&sdk=joey&show_facepile=true&show_posts=true" class=""></iframe>
我的尝试
$(document).ready(function(){
var $head = $("iframe").contents().find("head");
$head.append($("<link/>",
{ rel: "stylesheet", href: "style.css", type: "text/css" }));
});
或
var cssLink = document.createElement("link")
cssLink.href = "style.css";
cssLink .rel = "stylesheet";
cssLink .type = "text/css";
frames['iframe'].document.body.appendChild(cssLink);
我有很多谷歌,但找不到任何可行的解决方案。一些脚本在正常的 iframe 中工作,但在 facebook iframe 中没有任何工作。
我还创建了一个jsFiddle File
任何帮助将不胜感激!
【问题讨论】:
-
这样不行。您尝试访问跨域域 iframe
-
@OlegYudovich 我不知道跨域域 iframe,你在说这个吗{stackoverflow.com/questions/25098021/…}
标签: jquery html css facebook iframe