Failure to load CSS and JS files in PHP ci framework _php Tips

Source: Internet
Author: User
In the integration of HTML page inside the CI frame, loading css and JS failed, get a long time to find the CI framework is the framework of the portal, all the files in the framework of the request need to go through index.php processing, when loading external CSS and JS file to use the Base_ The URL () function handles external links.

Like what:

The base_url in the Config profile is: "localhost:8080/Project name/"

accessing application/resource/aaa.js files in the controller

Relative path <script src= "Resource/aaa.js" ></script> access failed

1, directly in the SRC output

<script src= "<?php echo Base_url ();? >.resource/aaa.js "></script>

2. Use Base label

Place the output of the Base_url () in the < Base href = "<?php echo base_url ();? > "/> tag inside, so in

The page inside the call is more convenient.
Copy Code code as follows:

< Base href = "<?php echo base_url ();? > "/>
<script src= "Resource/aaa.js" ></script>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.