2012-01-11 50 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