[eluser]Matalina[/eluser]
You can't use php in an external javascript file unless your php parser parses .js files, or if you extranal script is a .php with a javascript header at the start, but you can't call ci code inside of the external javascript file unless it's processed through ci with a controller.
I tend to do this for my straight js files: Note: remove the index.php part if you are using .httaccess to remove it.
Code:
$url = [removed].href.toString();
re = /^(http:\/\/\w*\.*(\w+\.\w+)\/.*)\/*index\.php*/;
matches = re.exec($url)
var $base_url = matches[0];
var $img_url = matches[1];
You'll have to use XMLHttpRequest as well to process said script.
If your javascript is in the view then you can use php like you have it.