I was trying to call "base_url()" inside of an external .js file.
my 'test.js' file path is "js/test.js".
my test.js code was:
function download(s){
var w=window.open('<?php base_url(); ?>home/download?f='+s+'.ogg','Download','height=100,width=100');
}
And I linked that file(my js file is working fine when trying simple JavaScript codes) :
<script src="<?php echo base_url(); ?>js/test.js" type="text/javascript"></script>
But that always said that the access was denied and asked for server permission.
I tried 'site_url()' too, even I tried just an echo "hello" in 'download' function but those didn't work. But when I add that code inside of header.php view file like:
<script type="text/javascript">
function download(s){
var w=window.open('<?php base_url(); ?>home/download?f='+s+'.ogg','Download','height=100,width=100');
}
</script>
Then that worked.
And in case of external CSS when I write:
background:url('<?php base_url(); ?>images/side.png');
That doesn't work. But if I write:
background:url('../images/side.png');
Then that works.
So how can I call "base_url()" inside of external .js file and .css file ?