function extractUrlValue(key, url) { if (typeof(url) === 'undefined') url = window.location.href; var match = url.match('[?&]' + key + '=([^&]+)'); return match ? match[1] : null; }
If you are trying to match the "url" from the page the visitor is currently on, you will use this method as follows:
var value = extractUrlValue('url');
Otherwise, you can pass your own url like
var value = extractUrlValue('url', 'http://www.test.info/link/?url=http://www.site2.com
source share