2012-01-11 47 views
0

下面是位於iframe中的代碼。JQUERY +更新帶有變量的HTML代碼

我可以從父文檔獲取變量'url',並可以在警報中看到它。

我需要能夠更新fb:like-box中的'http://www.domainname.com'文本。

這樣做的最好方法是什麼?

THX

<script type="text/javascript"> 
$(function() { 
    var url = $('div#facebookURL', window.parent.document).text(); 
    alert(url); 
}); 
</script> 
<div id="fb-root"></div> 
<fb:like-box href="http://www.domainname.com" width="237" height="498" show_faces="true"  stream="false" header="true"></fb:like-box> 

回答

0

您可以添加一些ID到你的樣箱,如:

 

<fb:like-box id="fbLikeBox" href="http://www.domainname.com" width="237" height="498" show_faces="true"  stream="false" header="true"></fb:like-box> 
//then 
$("#fbLikeBox").attr("href", url); 
 

希望它可以幫助

+0

完美...三江源! – Adam 2012-01-11 07:49:26