var testUrl1 = 'https://www.youtube.com/watch?v=qyCtwmlz1Dw';
var testUrl2 = 'http://feedback.ebay.it/ws/eBayISAPI.dll?LeaveFeedback2&_trksid=p2060353.m2749.l2665&useridto=tuttocarservice&item=191585964255&transactid=1150013914009';
//get some value using dot key notation
$('#result').append(getUrlParameter(testUrl1).v + '<br/>');
$('#result').append(getUrlParameter(testUrl2).transactid + '<br/>');
//open your browser console to see all key:value parameter
console.log(getUrlParameter(testUrl1));
console.log(getUrlParameter(testUrl2));
function getUrlParameter(url) {
var toReturn = {};
var questionSplit = url.split('?');
questionSplit.shift();
var onlyParameters = questionSplit.join('?');
var splittedParameters = onlyParameters.split('&');
for (var c = 0; c < splittedParameters.length; c++) {
var parts = splittedParameters[c].split('=');
if ($.trim(parts[0]) != '') {
toReturn[parts[0]] = parts[1];
}
}
return toReturn;
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.