[英]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.