My webpage needs a third party script, and that url is banned in some locations, I want to know, If there is any way I could find out whether the third script executed or not ?
Asked
Active
Viewed 36 times
0
-
3`if (typeof
!== "undefined") { ... }` – Andreas Jul 03 '15 at 13:20 -
@Andreas - Why comment but not an answer ? – Alp Jul 03 '15 at 13:23
-
@Andreas but if the external script changes than function and object will change,in that case i have to keep record of them – rbansal Jul 03 '15 at 13:35
-
@Andreas can I map it with the source location ? – rbansal Jul 03 '15 at 13:37
-
If the function/object... you're testing against gets changed or removed than you will have to adjust your script accordingly. If the url is blocked you could also try loading the url with a [XMLHttpRequest](https://developer.mozilla.org/en/docs/Web/API/XMLHttpRequest). If this fails (error, status, status code, response text, ...) you could assume that the external script also failed to load. – Andreas Jul 03 '15 at 13:41
-
@Andreas but it may slow down the web page loading if the script is big, for the users where url is accessible , Is there any method that can just ping the url and tell the response whether host is reachable or not ? I can safely assume that if url is accessible than definitely third party java script will load – rbansal Jul 03 '15 at 14:11
-
http://stackoverflow.com/questions/333634/http-head-request-in-javascript-ajax – Andreas Jul 03 '15 at 19:54