//URL is http://www.example.com/mypage?ref=registration&email=bobo@example.com $.urlParam = function (name) { var results = new RegExp('[\?&]' + name + '=([^&#]*)') .exec(window.location.search); return (results !== null) ? results[1] || 0 : false; } console.log($.urlParam('ref')); //registration console.log($.urlParam('email')); //bobo@example.com
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter