var newURL=window.location.pathname.split('/'); var newUrlArr=[]; newURL.forEach(function(item){ if(item != ""){ newUrlArr.push(item); } if(newURL.length > 5){ console.log('1212') newUrlArr.splice(item).push(item); } }); var newUrlArrLenth = newUrlArr.length - 1; var newURlSearch = newUrlArr[newUrlArrLenth] console.log(newURlSearch);
1.the code i write for split the url pathname to pass the parameters to search keyword. 2.when the href link is more than 3 slash need to replace a last word.
1.4m articles
1.4m replys
5 comments
57.0k users