function generateBC(url, separator) {
var splitthis = url.split("/");
var MiddleBit = [];
var RemoveFirstElement = splitthis.shift();
var RemoveLastElement = splitthis.pop();
var RemoveLastElementDot = RemoveLastElement.substring(0, RemoveLastElement.indexOf('.')).toUpperCase();
var arrayLength = splitthis.length;
for (var i = 0; i < arrayLength; i++) {
var elementOk = splitthis[i].toUpperCase();
var urlOk = "<a href='/pictures/'>" + elementOk + "</a>";
MiddleBit.push(urlOk);
}
var ConMiddleBitS = String(MiddleBit).replace(/,/g , separator);
var completed = '<a href="/">HOME</a> ' + separator + ConMiddleBitS + separator + "<span class='active'>" + RemoveLastElementDot + "</span>" ;
document.write(completed);
}
generateBC("mysite.com/pictures/hotels/tens/holidays.html", " : ");
的不確定的「替換」我不知道爲什麼我得到類型錯誤:無法調用在compareResults
TypeError: Cannot call method 'replace' of undefined at compareResults` on .replace() ?
有人可以請解釋原因,我認爲沒有錯上述。
謝謝你!
該代碼運行良好,沒有任何錯誤(不知道它是否做你期望的,但沒有在控制檯中的錯誤)。 https://jsfiddle.net/qoxcw5zo/ – spaceman