简体   繁体   中英

How to use same JS files for HTML pages?

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?

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!

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 ../ & ./

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM