url = 'http://www.yandex.ua/search?...' tst = url.split(/:?[\/]+/); var out=tst[2].split("?")[0]; if(out=='')out='/' if(out!=tst[2]&&(out=='webhp'||out=='search'||out.indexOf('#')==0||out=='/')) { alert('>'+out+'<'); }