![]() |
base_url () in JS file - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: base_url () in JS file (/showthread.php?tid=29946) |
base_url () in JS file - El Forum - 04-27-2010 [eluser]Zied[/eluser] How I can to execute base_url () in js file? I have problem to call images files in lightbox.js, the links are wrong and the photos is not appeared. fileLoadingImage: 'images/lightbox/lightbox/loading.gif', Thinks base_url () in JS file - El Forum - 04-27-2010 [eluser]steelaz[/eluser] You can set base url for the whole website by adding <base> tag in your header section: Code: <base href="<?= base_url(); ?>"/> So if your application resides in http://www.example.com/app/ and you call for assets (css, images, js) using relative path as in your example: Code: fileLoadingImage: ‘images/lightbox/lightbox/loading.gif’, Browser will actually look for it in http://www.example.com/app/images/lightbox/lightbox/loading.gif You can check the path browser is trying to access by loading Firebug. base_url () in JS file - El Forum - 04-27-2010 [eluser]Zied[/eluser] is the same problem. when I used Firebug, I found that (<base href="<?= base_url(); ?>"/> ![]() base_url () in JS file - El Forum - 04-27-2010 [eluser]steelaz[/eluser] When in Firebug, open "Net" tab, then "All" and refresh your page. Assets that can't be fetched will be in red and should give you a clue where the problem is. Also if it's possible, it would help if you could post a link to the page you're working on. base_url () in JS file - El Forum - 04-27-2010 [eluser]Zied[/eluser] It's the same problem, The project is on local host now, I will upload it and send you the URL page Thinks base_url () in JS file - El Forum - 04-27-2010 [eluser]umefarooq[/eluser] just define a global base_url in you html page or template before your scripts to call you can in your all js script files Code: in you html page or template file just define once before scripts removed is <script> base_url () in JS file - El Forum - 04-27-2010 [eluser]Caio Russo[/eluser] hi Zied, Try to use Code: <? = site_url(); ?> instead of base_url(); On my js I use that, and works well. base_url () in JS file - El Forum - 04-28-2010 [eluser]InsiteFX[/eluser] Try this, replace [removed] tags with you know what. Code: <head> InsiteFX |