0

Currenlt I am creating SharePoint hosted App. In which I have 2 pages Default .aspx and dashboard.aspx in Pages folder. Now I want to redirect page from Default to dashboard.aspx. One way I know is window.location = window.location.href.replace('Default.aspx', 'Dashboard.aspx'); But sometimes Default.aspx might have '#' key word at last,hence doesnt work many times and also we dont know if some other key work might come in default.aspx's URL. Hence want to any URL string manipulation. Please provide me some alternate solution in javascipt.

0

This windows.location.hash contains the anchor part of a URL. So

windows.location.assign(windows.location.href.replace(windows.location.hash,""));

Location Object

0

Use Relative Url to redirect to your custom pages Default Or Dashboard. This way you don't need to worry about URL hash #.

Simply use

window.location.href = "/sites/your-site/Pages/Dashboard.aspx"

This works 100% as it automatically calculates the domain and other params to form a web Url

  • there also we need SPHostUrl and someother parameter. In URL you mention doesnt contain complete required URL. – Akhilesh May 23 '18 at 8:06
  • I am only concerned to site Relative url. I know, this is a SP hosted app but one can easily get site url from both HOSTweb and APPweb Url. After this, it is a simple string manipulation problem. – DvG May 23 '18 at 8:56
  • Refer This Thread : sharepoint.stackexchange.com/questions/189927/… .. I hope this answers your query – DvG May 23 '18 at 8:58

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.