2016-07-26 94 views
0

我試圖找到我的工作目錄使用JavaScript的實際路徑。我從這個職位 How to get the absolute path of the current javascript file name如何獲得實際的Windows路徑使用javascript

<script> 
    alert(location.pathname); // /tmp/test.html 
    alert(location.hostname); // localhost 
    alert(location.search); // ?blah=2 
    alert(document.URL);  // http://localhost/tmp/test.html?blah=2#foobar 
    alert(location.href);  // http://localhost/tmp/test.html?blah=2#foobar 
    alert(location.protocol); // http: 
    alert(location.host);  // localhost 
    alert(location.origin); // http://localhost 
    alert(location.hash);  // #foobar 
</script> 

讀,但他們沒有,我一直在尋找,因爲我想找到例如「C:/ XAMPP/htdocs中/ myCurrentDirectory」的路徑。那麼如何做到這一點......?

在此先感謝... :)

回答

3

您不能。

URL和文件路徑之間的任何連接都由HTTP服務器完全內部處理(可能根本不存在)。這種關係沒有暴露給客戶,所以客戶端代碼不知道任何關於它的事情。

+0

Oooowh .... Okiee ..非常感謝您的信息.. :) –

相關問題