//Intercept the first occurrence in the incoming string The required string. Content between fieldName tag and endTag
function getQueryString(url,fieldName,tag,endTag){
var urlString = url;//document.location.href;
if(urlString != null){
var typeQu = fieldName tag;
var urlEnd = urlString.indexOf(typeQu);
if(urlEnd != -1){
var paramsUrl = urlString.substring(urlEnd typeQu.length);
var isEnd = paramsUrl.indexOf(endTag);
if(isEnd != -1){return paramsUrl.substring(0, isEnd);}
else{return paramsUrl;}
}
else {return null;}
}
else{return null;}
}
//Set the default page
function setDefaultPage(){
$("#contul ul ").html("");
$("#contul").hide();
$("#cont").show();
$("#top span") .find("a").removeClass("active");
$("#top span:eq(0)").find("a").addClass("active");
}
//Detect the final character
function checkCode(getParme){
if (getParme!=null){
getParme=getParme.toUpperCase();
var codeNum=getParme.charCodeAt(0 )
}
if(codeNum>=65&&codeNum<=91){
$("#top span").find("a").removeClass("active");
// alert((codeNum-64));
$("#top span:eq(" (codeNum-64) ")").find("a").addClass("active");
/ /$("#cont").html("");
$("#cont").hide();
$("#contul").find("ul").html( "");
runAjaxGetCode(getParme);
}else{
setDefaultPage();
}
}
//Perform ajax operation
function runAjaxGetCode(getParme){
//$("#cont").fadeOut('fast',function(){
$.ajax({
cache:false,
type:'get',
url:'sxml/searchByWord' getParme '.xml',
beforeSend:function(XMLHttpRequest){
$('
Data is loading, please wait< /div>')
.insertBefore( $("#cont") )
.fadeIn('slow');
},
success: function(data,textStatus){
$("#contul").show().find("ul").html("");
$(".quick-alert").fadeOut('slow', function(){
$(this).remove();
$("item",data).each(function(i, domEle){
$("#contul ul").append("
" getParme ":" $(domEle).children("title").text() " a>");
if(($(this).index()-6)%6==0){
$("#contul ul").append("< ;div class='clear'>
");
}
});
});
},
error: function(){
alert("Sorry, data acquisition failed, please refresh the page with F5 and try again. If the problem still exists, please contact the website administrator to solve it. ");
}
});
// });
}
//Get parameters
function getParmeter(){
getParme=getQueryString(urlParem,' #javascript=tagCode("','','")');
checkCode(getParme);
}
//getParmeter();
//Click trigger
$( "#top span:gt(0)").click(function(){
$(".quick-alert").remove();
});
//Initialization
$.history.init(function(url) {
//load(url == "" ? "1" : url);
if(url.length>0){
getParme=getQueryString( url,'javascript=tagCode("','','")');
if (getParme!=null){
getParme=getParme.toUpperCase();
checkCode(getParme);
}
}
else{
setDefaultPage();
}
});
//Other operations on the page
var getParme;
//function getHash(){
//var curHash = location.hash;
//alert(curHash);
//}
var urlParem;
urlParem=document.location.href;
var topHtml;
var topHtmlLink="";
var $_objTop;
$_objTop=$("#top")
topHtml=$_objTop.html();
for (var i=65;i <91;i )
{
topHtmlLink ="
" String.fromCharCode(i) "";
}
$_objTop.html(topHtml topHtmlLink);
Some demos are available here and included in the repository.