Javascript Return the url of the current page with no query string parameters - Code-Tips.com - Web Development, Programming, SEO

Sunday, February 13, 2011

Javascript Return the url of the current page with no query string parameters

This Javascript function strips/removes any existing query string parameters from the url and returns the 'cleaned' url.


function stripParameters()
{
   var loc = window.location.href;
   return loc.split("?")[0];
}



Next: Javascript Add query string parameter dynamically to some or all links on the current page

Previous: Javascript Get all parameters and values as an Array

Javascript Query String Manipulation (TOC)

0 comments:

Post a Comment