JS- get last URL with lastIndexOf

0 votes
330 views
added Feb 12, 2020 in Javascript by lcjr Lieutenant (12,460 points)
  1. newsUrl = window.location.href,
  2. newsId = newsUrl.substring(newsUrl.lastIndexOf('/') + 1);

 

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