Вопрос

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.

Это было полезно?

Решение

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

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

Location Object

Другие советы

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с sharepoint.stackexchange
scroll top