adapt url calls in javascript to /~userdir/ automatically
I'm working on a web app project shared on svn with many people, and we all have our test working folders on http://base-url/~username.
In certain javascript files, I call local urls (for autocompletion, for example), using the '/my/url' syntax. In the above setup, however, the url would work as '~username/my/url'. If I commit such code, however, each person has to开发者_如何学Go change the values every time they update. How can I dynamically add the prefix to the files?
thanks, manojo
With window.location.pathname you can get the path of the current page (so /~username/eventual/subfolders). So you can get the prefix based on that.
Sounds like you should be using relative urls and not absolute.
精彩评论