繁体   English   中英

如何链接到根目录中的文件

[英]How to link to file in root directory

我有一个网站,其根文件夹中有index.html ,还有一个名为apples的文件夹。 apples内部,我还有另一个index.html 目前,我正在尝试使用AngularJS将相同的导航栏加载到两个页面中。 但是,当我尝试像这样链接到Javascript文件: <script src="/controller.js"> ,JS文件将在根文件夹中为index.html加载,但拒绝为index.html加载该文件index.html apples文件夹中的index.html 有人知道为什么吗? apples文件夹中,它一直链接到apples//controller.js

<script src="../js/controller.js"></script>
          __ ______ ________
          |    |       |
          |    |       |___ 3. Get the file named "logo.png"
          |    |
          |    |___ 2. Go inside "images/" subdirectory
          | 
          | 
          |____ 1. Go one level up

参考

您是在服务器上还是在桌面上运行它? 如果从Web服务器运行,则/controller.js路径应该可以工作,但是如果在本地调用,则可能无法工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM