Home > Web Front-end > JS Tutorial > [JavaScript] Detect (judge) whether a link (URL) is valid (service available)

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

高洛峰
Release: 2016-11-25 13:39:43
Original
2540 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]:

Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template