[英]Add a custom style sheet inside a facebook iframe
我想自定義Facebook feed的設計,為此我想在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文件
任何幫助將不勝感激!
您無法以這種方式訪問或更改IFrame內容,因為這是跨域iframe。 您的瀏覽器將拒絕任何此類操作。 這正是你得到的: http : //screencast.com/t/Uu6TXWFW
是的,通常你可以修改iframe的內容,樣式等,但只有當它不是跨域時 - 你的域名不能修改Facebook iframe的內容。
其次 - 我不確定Facebook的規定是否合適 - 我的意思是修改其小部件和插件的樣式。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.