When integrating the html page into the ci framework, loading css and js failed. After a long time, I found that the ci framework is the entrance framework,
All requests for files in the framework need to be processed by index.php. When loading external css and js files,
Use the base_url() function to handle external links.
For example:
The base_url in the config configuration file is: "localhost:8080/project name/"
Access the application/resource/aaa.js file in the controller
Relative pathAccess failed
1. Output directly in src
<script src= "<?php echo base_url();?>.resource/aaa.js"></script>
2. Borrow base tag
Put the output of base_url() inside the
tagIt is more convenient to call it on the page.
<base href = "<?php echo base_url();?>"/> <script src= "resource/aaa.js"></script>