Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 682379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:35:21+00:00 2026-05-14T01:35:21+00:00

You can use the URL helper in Code Igniter to load CSS and Javascript

  • 0

You can use the URL helper in Code Igniter to load CSS and Javascript with the base_url() method, but what if you have images dynamically being placed into your HTML via javascript? for example in my javascript file I’ve got

var arrowimages={down:['downarrowclass', 'images/down.png', 23], right:['rightarrowclass', 'images/right.png']}

and those images will be placed into whatever menu item I’ve specified has a drop down menu.

but that file is a .js file so obviously the server won’t load php inside of it.

so, how can I set the base url for the JS?

Thanks!

-Aaron

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:35:21+00:00Added an answer on May 14, 2026 at 1:35 am

    Define a constant javascript variable like BASE_URI in the of your view, you can then reference this variable in any of your external javascript files.

    <head>
    ....
    <script type="text/javascript">
        var BASE_URI = "<?php echo base_url(); ?>";
    </script>
    ....
    </head>
    

    External js…

    var arrowimages={down:['downarrowclass', BASE_URI+'images/down.png', 23], right:['rightarrowclass', BASE_URI+'images/right.png']}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I write javascript code in ASP.NET MVC views, I can use @Url.Content() to
I know I can use window.location.pathname to return a url, but how do I
How can I use php to download an image from URL (eg: https://www.google.com/images/srpr/logo3w.png )
I wish to use the $html->image(...) helper function in CakePHP to output images, but
I have many widgets that can use JSON or JavaScript object literals as their
Right now I can use this URL to request a Google Static Maps image
I don't understand why in the url_split function I can use a++ , but
I need generate action links outside controllers. I can use Html.Action in Views, Url.Action
How can I use the '$.ajax()' technique, to provide the url parameter with a
I've notice that StackOverflow use this url: http://stackoverflow.com/posts/123123/revisions How can I add such routing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.