It is not possible to create files on the client's computer using Javascript.

By Saud Rana

The Code Style site uses relative URL paths with a leading forward slash, /; this means the URL is relative to the root level of the domain, not the current directory or “folder”. If you are adapting Code Style examples on a local file system, you will need to change these file references accordingly.

One of the key steps in externalising scripts is to ensure that all script file references are accurate.

Is the external file reference correct?
The Code Style site uses relative URL paths with a leading forward slash, /; this means the URL is relative to the root level of the domain, not the current directory or “folder”. If you are adapting Code Style examples on a local file system, you will need to change these file references accordingly.

The following examples use stylesheet references, but the same scheme applies to all external files including scripts and images.

./Style.css
Refers to the file Style.css in same directory as the HTML source, the "current" directory.
styles/Style.css
Refers to the file Style.css in a subdirectory of the current directory called styles.
../styles/Style.css
Refers to the file Style.css in a parallel directory called styles at the same hierarchical level as the current directory.
Has the script file loaded?
To check if an external script file has loaded, add the following code to the top of the file and reload the HTML in the browser:

// Debugging
alert('Script loaded.');
          
This should raise a dialogue box if the script loads (you may need to clear your browser's cache to force a reload). Once you're sure the script has loaded, put other temporary alerts into the script to find out which parts execute and which fail.

It is not possible to create files on the client's computer using Javascript.  (810 Views)