When integrating html pages into the ci framework, loading css and js failed. After half a day, I found that the ci framework is the portal framework, all requests to files in the framework must go through the index. php processing is complete. When loading external css and js files, use the base_url () function to process external links.
For example:
In the config configuration file, the base_url is: "localhost: 8080/project name /"
Access the application/resource/aaa. js file in the Controller
Access to the relative path <script src = "resource/aaa. js"> </script> fails.
1. output directly in src
<Script src = "<? Php echo base_url ();?>. Resource/aaa. js "> </script>
2. Borrow base tags
Put the base_url () Output in <base href = "<? Php echo base_url ();?> "/> Label, in this way
It is convenient to call on the page.
Copy codeThe Code is as follows:
<Base href = "<? Php echo base_url ();?> "/>
<Script src = "resource/aaa. js"> </script>