@
bigcoon 现在就是用的正则,可是不知道为什么会卡死浏览器,我的代码是这样的
function doAjaxCall(the_request){
$.ajax({
type:"get",
url:the_request,
dataType:"html",
success:function(result){
var ol = result+"";
var regTitle = /shelf-title-table[^.]*(\s*)[^.]*(\n)*(\r)*(.*)[^.]*(\?)*?menu-container/gm;
var mTitle,proName;
var reg = /yt-shelf-grid-item[^.]*(\s*)[^.]*(\n)*(\r)*(.*)[^.]*(\?)*?yt-shelf-grid-item/gm;
var m,i=0;
$("#program").empty();
while(i<7){
mTitle = regTitle.exec(ol)
//alert(regTitle.lastIndex)
proName = mTitle[0].match(/branded-page-module-title-text(\s*?)(.*?)<\/span>/)[0].replace("branded-page-module-title-text\">","").replace("</span>","");
var str = '<div class="nav"><ul><li><span>'+proName+'</span></li></ul></div>'+
'<div class="zd_con" id="zdCon'+i+'"><ul id="programList'+i+'">';
var j = 0;
strVertArr[i] = new Array();
reg.lastIndex = regTitle.lastIndex;
while(j<5){
m = reg.exec(ol);
var imgSrcURL = m[0].match(/src=".*?"/)[0].replace("src=\"","").replace("\"","");
var aHref = m[0].match(/href="\S*?"/)[0].replace("href=\"","
http://www.youtube.com").replace("\"","");
var name = '';//m[0].match(/yt-lockup-title[^.]*?(\s*?)(.*?)<\/h3>/)[0].match(/title="\S*?"/)[0].replace("title=\"","").replace("\"","");
var description = '';//m[0].match(/<li>[^.]*(.*)(\s*)(.*)[^.]*<\/li>/)[0].replace("<li>","").replace("</li><li>","-").replace("</li>","");
if(j<5){
if(j==0)
str += '<li><a id="a'+i+j+'" onkeydown="changeHome(event,\'\')" onfocus="return false;" ';
else
str += '<li><a id="a'+i+j+'" onkeydown="changeLoc(event,\'\')" onfocus="return false;" ';
str += ' href="javascript:goToPlay(\'' + aHref + '\');" class="scale-item movies big-cover">';
str += '<img class="big-img" src="'+imgSrcURL+'" />';
str += '<span class="wz"><h3>'+name+'</h3><p>' + description +'</p></span></a></li>';
}
strVertArr[i][j] = new AdItem(name,imgSrcURL,aHref,description);
j++;
//ol.replace(m[0]+"","");
}
//alert(reg.lastIndex)
str += '</ul></div>';
strArray[i] = str;
i++;
$("#program").append(str);
//ol.replace(mTitle[0]+"","");
}
$("#program").css("margin-bottom","20px");
$(".body-right").css("margin-top","0px");
}
});
}