Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Javascript function question : at start - at end

Posted on 2011-03-16
2
Medium Priority
?
410 Views
Last Modified: 2012-05-11
Hi all,

I have a javascript function that opens a dialog and I need to add something at the beginning and also tell in to do something when the dialog ends or end of the function.

for example:

function myFunction() {
    alert('Here it all starts');
   FB.init({
      appId:'43243', cookie:true,
      status:true, xfbml:true
      });

      FB.ui({ method: 'apprequests',
      message: 'message here!'});
     }

     //Finally  
     alert('The End');
 
   
}
0
Comment
Question by:error77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 25

Expert Comment

by:Luis Pérez
ID: 35146756
And what's the problem?
0
 
LVL 5

Accepted Solution

by:
vks_vicky earned 2000 total points
ID: 35146765
window.fbAsyncInit = function myFunction() {
    alert('Here it all starts');
   FB.init({
      appId:'43243', cookie:true,
      status:true, xfbml:true
      });

      FB.ui({ method: 'apprequests',
      message: 'message here!'});
     }

     //Finally  
     alert('The End');
   
}

function fbEnsureInit(callback) {
        if(!window.fbApiInit) {
            setTimeout(function() {fbEnsureInit(callback);}, 60);
        } else {
            if(callback) {
                callback();
            }
        }
    }

And the usage would be like

fbEnsureInit(function() {
    console.log("this will be executed once FB is initialized");
});

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

596 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question