有一个函数,它给了我urls如:
There's a function, which gives me urls like:
./some.css
./extra/some.css
../../lib/slider/slider.css
总是一个相对路径。
让我们认为我们知道页面的当前路径,例如 http://site.com/stats/2012/
,不知道如何将这些相对路径转换为真正的路径?
Let's think we know current path of the page, like http://site.com/stats/2012/
, not sure how do I convert these relative paths to real ones?
我们应该得到如下所示:
We should get something like:
./some.css => http://site.com/stats/2012/some.css
./extra/some.css => http://site.com/stats/2012/extra/some.css
../../lib/slider/slider.css => http://site.com/lib/slider/slider.css
没有jQuery,只有香草javascript 。
No jQuery, only vanilla javascript.