Hi Guys, recently i came across to find out whether the given set of URL's are broken links or not.
I have created below sample snippet to findout whether a URL exists Or not.
<html>
<head>
<script type = 'text/javascript'>
function IsUrlExists(url) {
var http = new XMLHttpRequest();
alert(http);
http.open('HEAD', url, false);
http.send();
alert(http.status);
return http.status != 404
}
</script>
</head>
<body>
<input type="text" name="Url" id="url">
<input type="button" value="Check" id="btncheck" onclick="IsUrlExists(document.getElementById('url').value);">
</body>
</html>
Hope this helps..
I have created below sample snippet to findout whether a URL exists Or not.
<html>
<head>
<script type = 'text/javascript'>
function IsUrlExists(url) {
var http = new XMLHttpRequest();
alert(http);
http.open('HEAD', url, false);
http.send();
alert(http.status);
return http.status != 404
}
</script>
</head>
<body>
<input type="text" name="Url" id="url">
<input type="button" value="Check" id="btncheck" onclick="IsUrlExists(document.getElementById('url').value);">
</body>
</html>
Hope this helps..
No comments:
Post a Comment