FBJS on facebook

I want to use javascript in my facebook app, but I don't know how to start with FBJS to use it. Someone will help me! just something like

<div onclick="greeting();">click me</div>
<script>
function greeting(){
  alert("hello world");
}
</script>
+3
source share
3 answers

This works for me:

<script type="text/javascript">
function areyousure(description,id,opt) {    var dialog = new Dialog(Dialog.DIALOG_POP).showChoice('Are you sure?','Are you sure you want to delete "' + description + '"? This action cannot be undone!','Yes','No');
    dialog.onconfirm = function() {
        document.setLocation("http://apps.facebook.com/myapp/delete.php?rec
ord=" + id + opt);
    }
}
</script>

.
.
.
<a href="#" onclick="areyousure(arg1,arg2,arg3)" ><img src="http://mysite/images/delete.png" /></a>
+3
source

A quick list of things that will deliver you and what you should use instead:

alert() -> no equivalent  
new Array() -> []  
new Object() -> {}  

Changes in the DOM "Big 2" change my code "back when":

innerHTML -> setInnerXHTML(), note that this is strict  
id -> getId()  

List all DOM changes .

Remember that FBJS is pretty poorly documented, so you have to play with some things to make things work.

+1
source

, Facebooks Dialog alert:

new Dialog().showMessage('Dialog', 'This is text');

http://thinkclay.com/technology/getting-started-with-facebook-js-fbjs

, :

<div onclick="greeting();">click me</div>
<script>
function greeting(){
  new Dialog().showMessage('Dialog', "hello world");
}
</script>
0

Source: https://habr.com/ru/post/1711314/


All Articles