Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • possible duplicate of How to find relative URL of a document library using CSOM Commented Jul 30, 2014 at 21:25
  • Yeah I have seen this question, but you need to provide manually the name of the library before getting the relative path. What I need is to get that relative url without passing any information of the library in which I am positioned. Is it posible to achieve this? Commented Jul 30, 2014 at 21:29
  • so you want the library url, without providing any meaningful information about the library? tough job. if the current url contains the information you want maybe you can parse it, e.g. var page = window.location.pathname.split('/').pop(); Commented Jul 30, 2014 at 21:45
  • Yeah. At this moment what I am doing is applying a script to the site once I enter the document library desired. So the only valuable information is that I am positioned at the document library when the script is loading and being applied. How I mentioned before, right now I have the SP service passing manually the name of the library, and it works perfectly. But I need it to work on 50 different document libraries, so I don't want the same script being loaded for each library, I am planning to add the script to the master page and work according to the document library that will be visited. Commented Jul 30, 2014 at 21:57
  • you can grab an example of the libs landing url and first validate if you are on a library, and then extract the library name, maybe resorting to regular expressions to help Commented Jul 30, 2014 at 22:08