Reasons and solutions to the failure of loading CSS and JS files in PHP ci framework _php Tips

Source: Internet
Author: User

When the HTML page is integrated into the CI frame, loading css and JS fails, and I find that the CI framework is the portal framework,

All requests for files in the framework need to be processed by index.php, and when loading external CSS and JS files, make

Use the Base_url () function to handle 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.

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