Javascript: Find directory of file


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



Copy this code and paste it in your HTML
  1. var url = "http://example.com/a/b/fish.html";
  2. url.substring( 0, url.lastIndexOf("/") );
  3.  
  4. // returns http://example.com/a/b

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.