angularjs - How to check webpage is available or not using javascript -


i want make web page request if web page available. have written app using angularjs + javascript. there way determine whether webpage available or not using javascript ?

if page in question on different origin, can't without using server somewhere or relying on other page implementing cross-origin resource sharing , supporting origin, because of same origin policy.

if page in question on same origin, can ajax call query it:

var xhr = new xmlhttprequest(); xhr.open("head", url); xhr.onreadystatechange = function() {     if (xhr.readystate == 4) {         if (xhr.status == 200) {             // worked         } else {             // didn't         }     } }; xhr.send(); 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -