画布上的 Facebook 应用程序:使用 JS 更改内容
我一直在尝试使用 JavaScript 修改 Facebook 上的画布应用程序上的 DIV,但它不起作用,也不会引发错误。我一直尝试使用innerHTML和FB的setInnerHTML,但没有成功。
有人遇到过这种情况或者知道该怎么办吗?这是不执行任何操作的代码:
var div = document.createElement("div");
div.setId("someNewId");
div.setInnerFBML("<p>dynamically added stuff</p>");
document.getElementById("someDivId").appendChild(div);
var div = document.createElement("div");
div.id = "someNewId";
div.innerFBML = "<p>dynamically added stuff</p>";
document.getElementById("someDivId").appendChild(div);
感谢任何帮助!谢谢!
I have been trying to modify DIVs on a canvas app on Facebook with JavaScript, but it doesnt work nor does it throw an error. I have been trying to use innerHTML and FB's setInnerHTML, to no avail.
Has anybody faced this situation or know what to do? Here is the code that doesnt do a thing:
var div = document.createElement("div");
div.setId("someNewId");
div.setInnerFBML("<p>dynamically added stuff</p>");
document.getElementById("someDivId").appendChild(div);
var div = document.createElement("div");
div.id = "someNewId";
div.innerFBML = "<p>dynamically added stuff</p>";
document.getElementById("someDivId").appendChild(div);
Any help is appreciated! Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实上,Facebook 已经宣布他们将弃用 FBML (http://developers.facebook.com/roadmap)。
由于您正在构建一个新应用程序,因此您会希望选择 IFrame 而不是 FBML - 如果您使用 IFrame,所有 javascript 都会运行得很好,并且您不必弄乱任何 FBJS 内容。您可以编写任何通常在浏览器中运行的 JavaScript,甚至可以使用 mootools、jQuery 或任何其他 JavaScript 库。
Actually, Facebook has announced that they are deprecating FBML (http://developers.facebook.com/roadmap).
Since you are building a new app, you would want to choose IFrame instead of FBML - and if you are using IFrame, all the javascripts would run just fine, and you don't have to mess with any of this FBJS stuff. You can write any javascript that would normally work in a browser and even use mootools, jQuery, or any other javascript libraries.
你把这段代码放在哪里?在用户交互之前,FBJS 不允许执行 JavaScript。尝试在 onclick 上运行该函数。
另外,如果您使用 firebug,console.log 也可以工作
Where are you putting this code? FBJS doesn't allow JavaScript to be executed until a user has interacted. Try running the function on an onclick.
Also if you're using firebug, console.log works