How can I link an HTML file in a different directory to JavaScript?

Viewed 43

This is the structure of my program. I wish to link HTML file from different directory into my JavaScript. Those html files are written with seperately functions.I wish to link into the script, making the index.html a multipurpose webpage. :

program structure

The code in my JavaScript is let var1= "../../../traffic_switch/traffic_switch.html", but it doesn't work. What should I do?

2 Answers

Are you trying to add a script to your HTML file?

If so then you will need to add this to the head of your traffic_switch.html file:

<script src="../Camera/static/js/config.js"></script>

Change road_switch for traffic_switch:

let path = "../../../traffic_switch/traffic_switch.html"
Related