I have a webpart and I want to reference a js file in the content link. But I don't want to hardcode the full absolute path. I want to use the relative url. The js is located in the style library folder.
The problem is I can't find out how to use the relative path. I tried
../../Style Library/username.js
But then this breaks if I use this same link in a subsite. Because the number of ..
is changed. I want a link that will work from anywhere. I tried ~sitecollection/Style Library/username.js
but SharePoint doesn't evaluate the ~
variable into the path. Does anyone know how to do this? Thanks.
http:/ /server/sites/sitename/Style Library/etc.js
I just use/sites/sitename/Style Library/etc.js
./sites/
is there in any environment, but thats only specific to your environment. I want something that will work in any environment.