我正在尝试在我的 application.js 中相对于当前页面定义一些 url 变量
/* Global Variables */
var base = document.location.href;
var http_video_base = base + "assets/videos/";
var http_academy_banner_base = base + "assets/banners/";
var user_academy_banner_image = "golf.jpg";
但这不起作用,当我的基本变量是
http://localhost/~yves/optimalPlayer/index.html I get an error (obviously )
Failed to load resource:
http://localhost/~yves/optimalPlayer/index.htmlassets/banners/golf.jpg
the server responded with a status of 404 (Not Found)
我应该将我的基本变量定义为包含当前页面的目录
http://localhost/~yves/optimalPlayer/
我应该如何定义 var base 以获得串联结果:
http://localhost/~yves/optimalPlayer/assets/banners/golf.jpg
谢谢你的建议