还在学习这个 jQuery 的东西....
我喜欢这个 ajax 页面加载器;它适用于<div id="content">
开箱即用的 Wordpress。但有一件事困扰着我:在 ajax 加载页面并旋转微调器时崩溃,我希望能够让 div 保留它的一些大小,而不是让页面的页脚向上然后向下跳跃。不必高于 500-600 像素,这样它就不会上下反弹页脚。这个函数的编写方式有可能吗?以下是最相关的功能。(我遗漏的其他内容必须与 Wordpress 及其 URL 结构有关。)
function loadPage(url){
if(!isWorking){
scroll(0,0);
document.getElementById('content').innerHTML='<center><img src="'+loadingIMG.src+'" /></center>';
http.open('GET',url,true);
isWorking=true;
http.onreadystatechange=showPage;
http.send(null);
}
}
function showPage(){
if(http.readyState==4){
if(http.status==200){
isWorking=false;
var content = http.responseText;
content = content.split('id="content"')[1];
content = content.substring(content.indexOf('>')+1);
var depth=1;
var output='';
while(depth>0){
temp = content.split('</div>')[0];
//count occurrences
i=0;
pos = temp.indexOf("<div");
while(pos!=-1){
i++;
pos = temp.indexOf("<div",pos+1);
}
//end count
depth=depth+i-1;
output=output+content.split('</div>')[0]+'</div>';
content = content.substring(content.indexOf('</div>')+6);
}
document.getElementById('content').innerHTML=output;
pageLoaderInit();
}else{
alert(http.status);
}
}
}