I am integrating a web application with facebook by following this tutorial
It is normally working but when AVG do not track is active the browser can’t load the Facebook JavaScript SDK so I want to show the user that in such a case he needs to disable the AVG do not track for the current website..
Is there a way to handle the loading error in JavaScript? We have try catch in Java – is there something similar in JavaScript so that I can hadle the loading error.
Sorry if this is a simple question … I am a noob when it comes to JavaScript 🙁
I attached a little function to give feedback at the end of the code supplied by the tutorial.
http://jsfiddle.net/PRvJs/1/
The problem is that because your script is running in a web app and the blocking is happening on the browser application level, you can only ever infer that things have gone awry, and even then you have to make assumptions – scripts have
loadanderrorevents but most Facebook blocking scripts circumvent that whole thing and just kill the HTTP request before it even goes out… so you can never really know!As a fallback, I made the subjective decision to wait 30 seconds and if there is still no
loadorerrorresolution to the script injection, makes the arbitrary [1] decision that something is fundamentally screwed somewhere between your code and Facebook. As far as I know, this is the most you can determine and the only way to determine it…[1] Most connections close if nothing has happened in 30 seconds.