lundi 2 février 2015

Issue with replacing apostrophe in URL string


I've tried escape, replace, split and join and I can't seem to get rid of the ' in the category title:


Over 60's



var dropdown = document.getElementById("cat");
if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
var currentText = this.options[this.selectedIndex].innerHTML;
var currentSlug = currentText.replace(/ |'/g, function(match){ if (match === " " || match === "'" ){ return "-"; } return "";}).toLowerCase();
location.href = "..url.. " + currentSlug;
} else {
location.href = dropdown.baseURI;
}
}
dropdown.onchange = onCatChange;


Is there a different method required in this scenerio





Aucun commentaire:

Enregistrer un commentaire