Facebook 应用程序 FBJS 帮助使用 setInnerXHTML +大批

发布于 2024-10-05 23:04:04 字数 1410 浏览 1 评论 0原文

我有一个画布Facebook应用程序,我在JS数组中拥有所有用户朋友,我想一一显示用户朋友的图片+姓名,单击“下一步”按钮后,我编写的代码不起作用:

<script> 
<!-- 
var friends = new Array(); //Friends Array
<?php
for($i=0; $i<= $limit; $i++) //Add to JS array all friends id's from PHP array
{
echo 'friends['.$i.'] = '.$appfriends[$i][uid].';';
}
?>

/*
I'm passing to this function the first Array --> 0 to increment it each time Next Friend clicked, and show the next friend picture then change Next Friend URL with the next friend Array Key
*/

function get_friends(id){ 
var fid;
fid = id++;
var fid_img = "<img src=\"https://graph.facebook.com/"+friends[fid]+"/picture\"/>";
var fid_link = "<a href=\"#\" onclick=\"get_friends("+fid+"); return false;\">Next Friend</a>";

//Changing Friend Image
document.getElementById('show_friends').setInnerXHTML(fid_img);

//Changing Next Friend URL
document.getElementById('next_friend').setInnerXHTML(fid_link);
}
//--> 
</script>

<div id="show_friends">
<img src="https://graph.facebook.com/<?php echo $appfriends[0][uid];?>/picture"/>
</div>

<br>

<span id="next_friend"><a href="#" onclick="get_friends(0); return false;">Next Friend</a></span>

FBJS文档:http://developers.facebook.com/docs/fbjs

抱歉我的英语不好。 提前致谢!

I have a canvas Facebook application, I have all user friends in JS array, and I want to show user friends picture + name one after one, after clicking NEXT button, the code i written is not working :

<script> 
<!-- 
var friends = new Array(); //Friends Array
<?php
for($i=0; $i<= $limit; $i++) //Add to JS array all friends id's from PHP array
{
echo 'friends['.$i.'] = '.$appfriends[$i][uid].';';
}
?>

/*
I'm passing to this function the first Array --> 0 to increment it each time Next Friend clicked, and show the next friend picture then change Next Friend URL with the next friend Array Key
*/

function get_friends(id){ 
var fid;
fid = id++;
var fid_img = "<img src=\"https://graph.facebook.com/"+friends[fid]+"/picture\"/>";
var fid_link = "<a href=\"#\" onclick=\"get_friends("+fid+"); return false;\">Next Friend</a>";

//Changing Friend Image
document.getElementById('show_friends').setInnerXHTML(fid_img);

//Changing Next Friend URL
document.getElementById('next_friend').setInnerXHTML(fid_link);
}
//--> 
</script>

<div id="show_friends">
<img src="https://graph.facebook.com/<?php echo $appfriends[0][uid];?>/picture"/>
</div>

<br>

<span id="next_friend"><a href="#" onclick="get_friends(0); return false;">Next Friend</a></span>

FBJS Documentation : http://developers.facebook.com/docs/fbjs

Sorry for my bad english.
Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

写下不归期 2024-10-12 23:04:04

我解决了这个问题,使用 FBJS 创建一个数组
你必须使用

<script> 
<!--
var arrayname = [];

//instead of

var arrayname = new Array;
//--> 
</script>

I solved the problem, to create an Array using FBJS
you have to use

<script> 
<!--
var arrayname = [];

//instead of

var arrayname = new Array;
//--> 
</script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文