I am using the following to get the active page url:
I am not sure if you want solution in Javascript. Here my suggestion Your Html code
Javascript Code
url = 'http://www.domain-nane.com/index.php?option=com_content&view=article&id=6&Itemid=111';
// url = '';
var urlRegex =/Itemid=([0-9]+)/i;
var Itemid = url.match(urlRegex)[1];
// alert(Itemid);
var nodes = document.getElementById('navigation').childNodes;
var lis;
for(i=0; i
Running Example http://jsfiddle.net/xdsUm/3/