function removeParameter(parameter)
{
//Get Query String from url
fullQString = window.location.search.substring(1);
paramCount = 0;
queryStringComplete = "?";
if(fullQString.length > 0)
{
//Split Query String into separate parameters
paramArray = fullQString.split("&");
//Loop through params, check if parameter exists.
for (i=0;i<paramArray.length;i++)
{
currentParameter = paramArray[i].split("=");
if(currentParameter[0] == parameter) //Parameter already exists in current url
{
//don't include existing (will be appended to end of url)
}
else //Existing unrelated parameter
{
if(paramCount > 0)
queryStringComplete = queryStringComplete + "&";
queryStringComplete = queryStringComplete + paramArray[i];
paramCount++;
}
}
}
window.location = self.location.protocol + '//' + self.location.host + self.location.pathname + queryStringComplete;
}
Showing posts with label QueryString. Show all posts
Showing posts with label QueryString. Show all posts
Monday, 16 April 2012
Javascript Remove a parameter from the query sring if found in current url
This Javascript function removes the supplied parameter from the query string if it is present in the current url. This is done by converting the query string into an array of parameters and values, then rebuilding the final string to exclude the parameter supplied to the function. The browser is then redirected to the current page with the new query string.
Javascript Get the value of the specified Query String Parameter
This Javascript function checks the address of the current page for the supplied query string parameter. If found, the value of the parameter is used, if the parameter is not found, false is returned.
See also: checkParemeterExists(), which returns true or false if the specified parameter is found or not.
function getParameter(parameter)
{
fullQString = window.location.search.substring(1);
paramArray = fullQString.split("&");
found = false;
for (i=0;i<paramArray.length;i++)
{
currentParameter = paramArray[i].split("=");
if(currentParameter[0] == parameter)
return currentParameter[1];
}
return false; //Not found
}
Javascript Check if Query String Parameter Exists in current URL
This Javascript function checks if the parameter supplied exists in the query string. If the parameter supplied is found in the query string of the current URL, the function will return true. If the parameter is not found, false is returned.
See also: getParameter() - This function returns the value of the parameter if found, and false if it is not found which can be used instead of the checkParameterExists() function below
function checkParemeterExists(parameter)
{
//Get Query String from url
fullQString = window.location.search.substring(1);
paramCount = 0;
queryStringComplete = "?";
if(fullQString.length > 0)
{
//Split Query String into separate parameters
paramArray = fullQString.split("&");
//Loop through params, check if parameter exists.
for (i=0;i<paramArray.length;i++)
{
currentParameter = paramArray[i].split("=");
if(currentParameter[0] == parameter) //Parameter already exists in current url
{
return true;
}
}
}
return false;
}
Subscribe to:
Posts (Atom)
Popular Posts
-
To see a site collection's hidden user information list append /_catalogs/users/simple.aspx onto the end of the site collection url. ...
-
Please Check the below complete code to bind SharePoint list items to a DataTable/ Gridview. In this post, we are using the list named ...
-
To bind the drop down list data with a field from the SharePoint list you can use the below code methods:- Method 1 if (!Page.IsP...
-
By Default SharePoint shows 3 events for any date in the calendar view, if we want to show all the events then we have to use any of the fol...
-
This Javascript function checks if the parameter supplied exists in the query string. If the parameter supplied is found in the query strin...
-
You can use CAML to do the following: Modify parameters to transport complex data Define the body of SOAP messages to transport data usin...
-
You can use below powershell command to change sharepoint user display name. Set-SPuser -identity "User name" -DisplayName ...
-
SharePoint solutions are either deployed globally or targeted to a particular web application. The decision of which is made automatically...
-
The sharepoint site is very slow when we access it first time. After that the response time is good. The reason is compilation and cachin...
-
The following Event Handler code will prevent users from creating duplicate value in "Title" field. ItemAdding Event Handler ...