In my SharePoint hosted app, I am getting an URL like https://<Domain>-ffc9b07d6c583f.sharepoint.com/sites/Trial/EMS/Pages/Default.aspx but I need to achieve like thishttps://<Domain>.sharepoint.com/sites/Trial/EMS/Pages/Default.aspx.

I have gone through this, but it works only in the case if I have SPHostUrl in the Query strings. Kindly suggest


Unfortunatelly there is no easy way how to get the host web url. You can simply remove the part between dash and first dot. The text between them is dynamic and changes with each new version of application. But it is always in the same format.

var url = "https://<Domain>-ffc9b07d6c583f.sharepoint.com/sites/Trial/EMS/Pages/Default.aspx";
url.replace(url.substring(url.indexOf("-"), url.indexOf(".")), "");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.