Blog

TypeScript functions to get current domain, site collection and Site urls with window.location fallback

image

Hi,

Recently I was working in a TypeScript project building a SPA application on top of Office 365 and I needed to get the current domain, current site collection and current site urls for using them in a different React components.

The case is we always rely on _spPageContextInfo to get this information, but in fact, we can use window.location object to build the urls as a fallback in case we need to use this Utils library before SP.js loaded or in other context.

Here is my solution for that problem using TypeScript:

 

HTH

@jquintozamora

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.

Post Navigation