2016-04-12 42 views
0

我試圖訪問位於我的index2.html文件的父目錄中的hellotest.js。
我沒有這樣做的運氣,修復應該很簡單,我試過尋找答案。
的絕對路徑的文件(的Ubuntu/Linux的):
/home/petrus/dev/testbeds/http-server/index2.html /home/petrus/dev/testbeds/hellotest.js通過HTTP服務器上的父級目錄訪問HTML文件中的JavaScript文件

編輯:我是一個HTTP服務器上運行此:http-serverSimpleHTTPServer

<!DOCTYPE HTML> 
<html> 
<head> 
    <script src="../hellotest.js" type="text/javascript"></script> 
    <title>test website</title> 
</head> 
<body> 
    <p>hello world 2</p> 
</body> 
</html> 
+0

不要擔心爲什麼我要這樣做,我會訪問文件3個目錄和4個目錄下來,一旦我得到這個工作。 –

+0

你得到什麼樣的錯誤?您正在使用Web服務器還是僅將該頁面加載到瀏覽器中? – Cyb3rFly3r

+0

我正在使用http-server:https://www.npmjs.com/package/http-server 也嘗試與SimpleHttpServer:https://docs.python.org/2/library/simplehttpserver.html –

回答

0

我最終通過創建符號鏈接解決了這個問題。
在Linux/Ubuntu中,你可以這樣做:ln -s <symlink_origin> <symlink_destination

-1

而不是使用..最多導航到父目錄只需要使用目錄名。嘗試testbeds/hellotest.js。

+0

沒有運氣,嘗試過,甚至放在絕對路徑。 也嘗試了絕對路徑,如下所示:'file:/// home/petrus/dev/testbeds/hellotest.js' –

相關問題