Why no file not found error and purpose of checkJS function


I have written the following code from a Php book:

<!DOCTYPE html>
<html lan="en">
<title>Dog Object</title>
<script src="validator.js"></script>
<style type="text/css">
#JS { display:none; }
function checkJS() {
document.getElementById('JS').style.display = "inline";
<body onload="checkJS();">
<h1>Dog Object Creater</h1>
<div id="JS">
<div id="noJS">

The output is:

Dog Object Creater

I have 2 questions:

  1. This program uses validator.js file.I don’t have validator.js file. Why I am not getting file not found error?
    2)The above program has checkJS() function. What is the purpose of checkJS function?
    Somebody please guide me.


Hi @Zulfi6000, you should see a not found status code in the network panel of the browser dev tools though.

Something like this is usually done to add a js-enabled class (or similar) to the body, so that you can account for deactivated JS in your CSS – show a “please enable JS” message if it is missing, for example. I don’t see much purpose in just displaying an empty div though.

1 Like

I saw the name Validator.js in one message. One example error message is:

[HTTP/1.1 404 Not Found 0ms]

For this I pressed: CTRL+SHIFT+J

God blesses you.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.