Path取得路徑,移除檔名 str="../../aaaa/bbb/ccc.html"; str1=str.substring(0, str.lastIndexOf("/")); alert(str1) 輸出: ../../aaaa/bbb/ Doc navigation← 移除部分字串