I am trying to make a cordova wrapper for a hosted web App. I need to catch the event for server error for the requested URL. Remember i am opening the URL by using Window.location.href. Please suggest ?
You can't do it using window.location.href
. You can send a GET
request however using Ajax and see what code you get back before actually going to that website.
var req = new XMLHttpRequest();
req.open('GET', 'http://www.example.org', true);
req.send();
if (req.status != "200") {
// Error
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.