Home > Back-end >  How to use same JS files for HTML pages?
How to use same JS files for HTML pages?

Time:05-07

At the moment, the files setup looks like this: File Setup in the merkur.html file I use this to go to the JS files:

<script src="../scripts/ui.js"></script>
<script src="../scripts/index.js"></script>

The JS is only working on the index.html, in the merkur.html I get the error: Error Message

Can somebody help me?

CodePudding user response:

In your index.html file, keep the links to your JavaScript files as bellow.

<script src="scripts/ui.js"></script>
<script src="scripts/index.js"></script>

In your merkur.html file, keep the links to your JavaScript files as bellow.

<script src="../scripts/ui.js"></script>
<script src="../scripts/index.js"></script>

If you are still getting errors, you may have do something wrong in your JavaScript codes. Maybe you are trying to search for an HTML element which doesn't exist in your relevant HTML code.

Thanks and best regards!

CodePudding user response:

You can use js files in any html document. The only one problem here is a path you wrote for merkur.html file.

So just read how to deal with path to files. Especially ../ & ./

  • Related