Welcome Guest, Not a member yet? Register   Sign In
Javascript broken paths issue
#3

[eluser]mddd[/eluser]
You need to realize that the browser treats a CI application just like any other website. If your page is /controller/method/argument and you link to your js-files as "js/script.js" then the browser is going to look for that file in /controller/method/js/script.js. And that doesn't exist. You need to explicitly tell the browser where the file is, and not use a relative path because that will look different to the browser depending on how your url looks for each page.

One way to do this is as Clifford James points out: use the site_url of base_url functions. They will put in your site's url from config.php and make a consistent location. You could also just use absolute urls from the root of your site, like "/js/script.js". Using the functions has the advantage of easier moving around of the entire site if you want to do so in the future.


Messages In This Thread
Javascript broken paths issue - by El Forum - 08-19-2010, 06:04 PM
Javascript broken paths issue - by El Forum - 08-20-2010, 02:45 AM
Javascript broken paths issue - by El Forum - 08-20-2010, 02:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB