JS- get last URL with lastIndexOf

0 votes
184 views
added Feb 12, 2020 in Javascript by lcjr First Warrant Officer (11,070 points)
newsUrl = window.location.href,
newsId = newsUrl.substring(newsUrl.lastIndexOf('/') + 1);

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...