javascriptno-framework

How to get a part of a url string with pure javascript


I have this url, for example:

https://www.google.com/calendar/render#main_7%7Cmonth

I need to get ONLY calendar with or witout /

Why in pure JavaScript? I want to put it in a bookmark, so i cant use any kind of JS.Framework...

Some of you could say that post is duplicated. Thats why you dont use the search-tool nor read the entire question. Thanks for other who really read everything.

PD:Yeah, i've readed this solution.. this does not fit me. JavaScript - Get Portion of URL Path


Solution

  • Use split function to divide string to array:

    "https://www.google.com/calendar/render#main_7%7Cmonth".split('/')[3];