Given an absolute URL to an item, like:
or the absolute URL to the item's parent list, like:
how can I get the URL of the item's parent web, in JSOM?
(In this case,
This is in the context of an Item Display Template for a Content Search web part. I know that there is a property you can retrieve from the
SPSiteURL, but that is either the URL of the site collection or the URL of the site that the Content Search webpart is on (they happen to be the same in my case, hence the ambiguity), and I want the URL of the sub-web that the item is on.
What's the best way to do this? I know I can resort to string manipulation (i.e. cut off the item's URL where "/Lists..." starts), but I'd rather do it a better way.
Just to be clear, the Content Search web part where this code will be executing is in the root web of the site collection:
The item is in a list in a subsite:
What I am looking for is the URL of the web where the list that the item comes from is located:
Which in this case is below where the code is executing in the site hierarchy.