I followed the structure from the book “Javascript and Jquery Interactive front-end and web development tool”
a main JavaScript Projects folder is saved onto the C drive, then a sub folder with named “c02” which is the name of the chapter, then another sub folder which holds my html file and a separate folder titled “js” which holds the javascript file.
I followed the same steps as the book so I do not know how it would not work with my file.
Yes, having an HTML page trying to access a file from the file system is not what you want.
That is, instead of having a src like file://C it should be either an absolute path like http://localhost/javascript/myjavascriptfile.js or a relative path to the file that is under the “localhost” domain.
My recommendation is to install node js and use the http-server package to run a local server on your machine for development. You always want to use machine/environment agnostic file paths so that projects can easily be uploaded to other server environments like production with minimal changes.
Or try usbwebserver, which you just have to download and extract to a folder. Zero configuration required to make it work. Create a folder for each test site and save the files and sub folders in the site’s folder.
Includes php and mysql as well as running a web server.
Very much easier to use than some of it’s rivals.
And as mentioned above, don’t hard code a script to you c: drive, as it will never work online.
You mentioned this folder C:/JavaScript%20Projects/c02/js/stjs.js
Are your html files in this one C:/JavaScript%20Projects/c02 or somewhere else?
For src=“js/stjs.js” to work, the html files should be in the folder immediately above js
you should have a folder structure similar to this
sitename
sitename/www - where the html files live
sitename/www/images
sitename/www/js
sitename/imagedump for original images which get edited and saved in the www/images folder
sitename/docs for documents and other stuff about the site. for example a collection of documents / clips from other sites about each page’s topic that you are going to take parts from and re-write to make the page.
I would argue that installing a local LAMP environment for serving up static files is an over kill. All you need to do with http-server is install it via npm and and run a single command in the terminal. To each their own.