0
我有http://www.example.com/page/3/斜槓後刪除地址欄中的網址。如何使用location.pathname.substring(1)
現在我想使用javascript去除「/ page/3 /」。
當我谷歌的解決方案,我發現「location.pathname.substring(1)」,但不知道我將如何實現它。
謝謝
我有http://www.example.com/page/3/斜槓後刪除地址欄中的網址。如何使用location.pathname.substring(1)
現在我想使用javascript去除「/ page/3 /」。
當我谷歌的解決方案,我發現「location.pathname.substring(1)」,但不知道我將如何實現它。
謝謝
嘗試使用此功能。
var addressValue = document.location.pathname.substring(1);
var addressParts = addressValue.split(/\//);
var result = addressParts[0];
alert(result);