Are you first timer at Why not join us and start exchange your programming knowledge with everyone. Register today!

JS - Get specific slash value on URL with split()

0 votes
added Feb 12 in Javascript by lcjr Sergeant (2,320 points)
var newsUrl = window.location.href,
    newsSplit = newsUrl.split('/'),
    newsId = newsSplit[newsSplit.length-2]; 

// e.g URL:

// output newsId
// 1643743


Please log in or register to response this reference. - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.