In CSS, any image path is relative to the CSS file location.
f.ex if I put the CSS file in /media/css/mystyles.css
and use something like
As other posters mentioned you need to compute your base url for the script first, you can the script below to find it.
// find the base path of a script
var settings = {};
settings.basePath = null;
if (!settings.basePath) {
(function (name) {
var scripts = document.getElementsByTagName('script');
for (var i = scripts.length - 1; i >= 0; --i) {
var src = scripts[i].src;
var l = src.length;
var length = name.length;
if (src.substr(l - length) == name) {
// set a global propery here
settings.basePath = src.substr(0, l - length);
}
}
})('myfile.js');
}
log(settings.basePath);