Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FBJS in facebook

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

<div onclick="greeting();">click me</div>
<script>
function greeting(){
  alert("hello world");
}
</script>
like image 845
gacon Avatar asked Feb 11 '26 21:02

gacon


2 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>
like image 67
Mike Heinz Avatar answered Feb 13 '26 14:02

Mike Heinz


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

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

The "Big 2" DOM changes, that broke a lot of my code "back when":

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

A list of all the DOM changes.

Beware that FBJS is pretty poorly documented, so you'll have to play around with some things to get everything working.

like image 30
Kevin Montrose Avatar answered Feb 13 '26 16:02

Kevin Montrose



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!