如何獲取沒有文檔名稱的文檔路徑?例如:沒有文檔的路徑
window.document.location
給我:http://host.com/lorem/ipsum/document.php
,我只需要得到:http://host.com/lorem/ipsum/
。
將是偉大的幫助。
如何獲取沒有文檔名稱的文檔路徑?例如:沒有文檔的路徑
window.document.location
給我:http://host.com/lorem/ipsum/document.php
,我只需要得到:http://host.com/lorem/ipsum/
。
將是偉大的幫助。
var loc = location.href;
loc = loc.substring(0, loc.lastIndexOf("/"));
這個對我很好。謝謝大家! – Tomarz 2012-02-15 17:04:11
正則表達式或簡單的JavaScript。它與'jQuery'無關' – gdoron 2012-02-15 16:31:34
好吧,我已經刪除了標籤。 – Tomarz 2012-02-15 16:32:27
@gdoron。謝謝。 – 2012-02-15 16:32:34