Q:

jQuery redirect to source url

I would like to redirect a user to a target URL on a button click. The target URL is variable and has to be read from the current page URL parameter 'source':
For instance, I have a url http://w/_l/R/C.aspx?source=http://www.google.com 
When the user clicks on a button he's being redirect to http://www.google.com
How would I do that with jQuery?

A:

first of all you need to get the url param : source 
this can be done with a function like :
function GetParam(name) {
    return decodeURI(
        (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
    );
} 

// you can use it like 
var source = GetParam('source');
//then
window.location.href = source

