Get Page Url in SharePoint Framework (SPFx) - No JavaScript Framework

Ravindranath M 1 Reputation point
2022-02-01T09:59:37.383+00:00

Hi,

I need to get full page Url address in SPFx using No JavaScript Framework.

tried with location.href but no proper url structure

Microsoft 365 and Office | SharePoint | Development
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Rob Windsor 2,001 Reputation points
    2022-02-01T11:00:57.137+00:00

    What issue are you having with window.location.href? That is what I use to get the page URL and I don't recall ever having issues.

    170099-image.png

    170110-image.png


  2. RaytheonXie_MSFT 40,471 Reputation points Microsoft External Staff
    2022-02-02T02:31:59.827+00:00

    Hi @Ravindranath M ,
    Per my test, I agree with RobWindsor-4651's function to get current page url. It works well. You can try the code in the answer. If there is any issue, you can provide the error message for further
    test.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.