Welcome Guest, Not a member yet? Register   Sign In
where to put javascript
#16

[eluser]Pascal Kriete[/eluser]
alex-and-r, base_url() gives you the path that you set in your config file. Then just add the rest of the path to the javascript file.

Here's an example:
[pre]
public_html
- ci
-- index.php
-- application
-- javascript (js files go in here!)
-- system
[/pre]
In this case base_url would give me example.com/ci (assuming I've set it correctly). So then I add javascript/filename.js.
Code:
<script src="<?= base_url(); ?>javascript/filename.js"></script>

The easiest way to work out problems with this is to view the source of the rendered page, to see where it's going wrong.


Messages In This Thread
where to put javascript - by El Forum - 10-31-2008, 01:16 AM
where to put javascript - by El Forum - 10-31-2008, 01:58 AM
where to put javascript - by El Forum - 10-31-2008, 02:10 AM
where to put javascript - by El Forum - 10-31-2008, 11:33 AM
where to put javascript - by El Forum - 10-31-2008, 11:46 AM
where to put javascript - by El Forum - 10-31-2008, 12:17 PM
where to put javascript - by El Forum - 10-31-2008, 02:02 PM
where to put javascript - by El Forum - 10-31-2008, 04:53 PM
where to put javascript - by El Forum - 11-02-2008, 09:20 PM
where to put javascript - by El Forum - 11-02-2008, 09:35 PM
where to put javascript - by El Forum - 11-02-2008, 09:40 PM
where to put javascript - by El Forum - 11-02-2008, 09:49 PM
where to put javascript - by El Forum - 11-02-2008, 10:00 PM
where to put javascript - by El Forum - 11-02-2008, 10:05 PM
where to put javascript - by El Forum - 11-18-2008, 01:46 AM
where to put javascript - by El Forum - 11-18-2008, 01:54 AM
where to put javascript - by El Forum - 11-18-2008, 01:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB