Q:

How to extract string values from a URL?

I want to extract following values from the url mentioned below? 

layout2
aqua

code:
var url = "http://localhost:8080/dflyers/edit.html?layout2&aqua"
var dataLayout = // I need url string (layout2) here
var dataTheme = // I need url string (aqua) here

Can some one help to get mentioned values using jQuery/Javascript? Thanks

A:

Well, if you just want to get those values from the mentioned url, and not any complex url parser, the most simple solution is:
var url = "http://localhost:8080/dflyers/edit.html?layout2&aqua";
var query = url.split('?')[1].split('&');
var dataLayout = query[0];
var dataTheme = query[1];

alert('layout '+dataLayout);
alert('theme '+dataTheme);​

Example running in jsfiddle

