Extract folder from window.location.pathname


/ Published in: JavaScript
Save to your folder(s)

* example: google.com/reader/view/

folder = /reader

* example: google.com/reader

folder = /

* example: google.com

folder = ''


Copy this code and paste it in your HTML
  1. var folder = window.location.pathname.substring(window.location.pathname.indexOf('/', 0), window.location.pathname.indexOf('/', 1));

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.