Get Query String parameters using JavaScript

In SharePoint, we use custom client side script (jQuery) to load or submit content on a page, some time we also need to get few values from Query string. There are multiple ways of doing that, here I am going to share a function to which you just need to pass the query string field and it will return the value.

The function call is very simple. For example you on a page having URL https://mstechtalk.sharepoint.com/Lists/Tasks/EditForm.aspx?List=9196139c-84a6-4d83-b375-c94e861c7637&ID=1793&Web=48b8f4ce-c0a6-4d81-a385-667c9a80cba5&PageView=Shared&InitialTabId=Ribbon.WebPartPage&VisibilityContext=WSSWebPartPage

Now you have to get the List item id, you can the ID query string in above URL, simply call the function to get the specific query string.

 

The following two tabs change content below.
Adnan Amin
Adnan is two time SharePoint MVP (Most Valuable Professional) with over 12 years of extensive experience with major expertise on SharePoint Server, Office 365, .Net Platform and Microsoft BI. He is currently working SharePoint Architect at FMT Consultants. He is MCT Regional Lead for Pakistan Chapter since 2012. He is working on SharePoint for past nine years and worked on different intranet/intranet solutions for private & govt. sector majorly in Gulf region, which include OOB and customized solutions. He is a trainer, technology evangelist and also speaks in community forums.

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *