从主目录引用 javascript 文件
我有 2 个目录,a
和 b
。 a
包含需要引用 b
中的脚本文件的页面。
我该怎么做?我似乎记得我必须做类似的事情:
<script src="../b/jquery-1.6.min.js" type="text/javascript"></script>
I have a 2 directories, a
and b
. a
contains a page that needs to reference a script file in b
.
How do I do this? I seem to remember that I have to do something like:
<script src="../b/jquery-1.6.min.js" type="text/javascript"></script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您从
http://example.com/a/foo.html
提供页面,那么包含该代码应该从http://example.com/b/jquery 加载脚本-1.6.min.js
除非您的页面中有
。如果它似乎不起作用,请在页面上放置一个链接
并加载该页面并单击该链接。您可以通过浏览器的 URL 栏查看完整的 URL。
如果链接 URL 与您预期的不符,则您的页面中可能存在
。让我们知道这将帮助我们找到适合您的相对 URL。如果 URL 没问题,但是 JS 的内容没有在浏览器中显示,那么你的服务器可能配置错误。我们需要有关您的服务器的更多详细信息才能提供反馈。
If you serve the page from
http://example.com/a/foo.html
, then including that code should load the script fromhttp://example.com/b/jquery-1.6.min.js
unless you have a<base href="...">
in your page.If it doesn't seem to be working, put a link on your page
and load the page and click the link. You can see the complete URL by looking at your browser's URL bar.
If the link URL is not as you expect, you probably have a
<base href="...">
in your page. Letting us know that will help us find a relative URL that works for you.If the URL is ok, but the content of the JS does not show in the browser, then your server is probably misconfigured. We would need more details about your server to provide feedback on that.