Home > Web Front-end > JS Tutorial > body text

[JavaScript] Detect (judge) whether a link (URL) is valid (service available)

高洛峰
Release: 2016-11-25 13:39:43
Original
2458 people have browsed it

How to use javascript to determine whether the requested url/link is valid (connectable, usable)?

Introduction

There is an address book system deployed on several servers at the same time, but there is a link to the address book on the homepage, link to The problem with this system is that sometimes the server to which the link points fails, so we hope that when this server fails (the service is unavailable), we can point to links to other servers.

Solution 1: XMLHTTP solution

The following code Excerpted from meizz's reply in [2]:

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template