簡體   English   中英

獲取沒有最終文件名的當前路徑

[英]Get current path without final file name

我試圖從腳本文件中獲取一個路徑,以便在腳本內部使用但沒有最終文件名。

例如:

http://www.domain.com/folder/

所有我的“window.location”都沒有工作,在我的測試中,我得到“ http://www.domain.com ”或“final_filename.php”

如何在沒有最后一個final_filename的情況下獲得所有子文件夾的路徑?

var pathParts = window.location.pathname.split('/');
var path = window.location.pathname.replace(pathParts[pathParts.length-1],'');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM