主要函数:
复制代码 代码如下:
<!--
function getObject(objectId) {
if(document.getElementById && document.getElementById(objectId)) {
// W3C DOM
return document.getElementById(objectId);
}
else if (document.all && document.all(objectId)) {
// MSIE 4 DOM
return document.all(objectId);
}
else if (document.layers && document.layers[objectId]) {
// NN 4 DOM.. note: this won't find nested layers
return document.layers[objectId];
}
else {
return false;
}
}
var responsecont;
var xmlHttp;
var requestType;
var newsstring;
function CreateXMLHttpRequest(){
// Initialize Mozilla XMLHttpRequest object
if (window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
// Initialize for IE/Windows ActiveX version
else if (window.ActiveXObject) {
try{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP.3.0");
}
catch (e){
try{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){newsstring = "<div class='loading'>Loading rquest content fail, Please try it again latter...</div>";}
}
}
}
function getnews(tagid,x){
var url = tagid+'_'+x+'.htm';
var loadstatustext="<div class='loading'><img src='images/loading.gif' /> Loading request content, please wait...</div>";
requestType = tagid;
CreateXMLHttpRequest();
getObject(requestType+'_cnt').innerHTML = loadstatustext;
xmlHttp.onreadystatechange = processRequestChange;
xmlHttp.open("GET", url, true);
xmlHttp.setRequestHeader("If-Modified-Since","0");
xmlHttp.send(null);
}
function processRequestChange(){
// only if xmlHttp shows "complete"
if (xmlHttp.readyState == 4){
// only http 200 to process
if (window.location.href.indexOf("http")==-1 || xmlHttp.status == 200){
newsstring = xmlHttp.responseText;
//inject centent to tab-pane
shownews(requestType,newsstring);
}
}
}
function shownews(requestType,newsstring){
//<![CDATA[
responsecont = getObject(requestType+'_cnt');
responsecont.innerHTML = newsstring;
//]]>
}
function TabNews(tagid,x){
for (var i=1;i<=7;i+=2) {
if (i == x) {
getObject(tagid+i).className="tabactive"+i;
if(i!=1){
getObject(tagid+(i-1)).style.display="none";
if(i!=7){
getObject(tagid+(i+1)).style.display="none";
}
}
if(i==1){
getObject(tagid+"2").style.display="none";
}
try{
getnews(tagid,i);
}
catch(e){
alert(e);
}
}
else
{
getObject(tagid+i).className="";
if(i!=7){
getObject(tagid+(i+1)).style.display="block";
}
}
}
}
//-->
调用方法:
复制代码 代码如下:<li style="cursor:pointer" id="tab3" onclick="TabNews('tab',3)">最新折扣信息</li>
复制代码 代码如下:
<!--
function getObject(objectId) {
if(document.getElementById && document.getElementById(objectId)) {
// W3C DOM
return document.getElementById(objectId);
}
else if (document.all && document.all(objectId)) {
// MSIE 4 DOM
return document.all(objectId);
}
else if (document.layers && document.layers[objectId]) {
// NN 4 DOM.. note: this won't find nested layers
return document.layers[objectId];
}
else {
return false;
}
}
var responsecont;
var xmlHttp;
var requestType;
var newsstring;
function CreateXMLHttpRequest(){
// Initialize Mozilla XMLHttpRequest object
if (window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
// Initialize for IE/Windows ActiveX version
else if (window.ActiveXObject) {
try{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP.3.0");
}
catch (e){
try{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){newsstring = "<div class='loading'>Loading rquest content fail, Please try it again latter...</div>";}
}
}
}
function getnews(tagid,x){
var url = tagid+'_'+x+'.htm';
var loadstatustext="<div class='loading'><img src='images/loading.gif' /> Loading request content, please wait...</div>";
requestType = tagid;
CreateXMLHttpRequest();
getObject(requestType+'_cnt').innerHTML = loadstatustext;
xmlHttp.onreadystatechange = processRequestChange;
xmlHttp.open("GET", url, true);
xmlHttp.setRequestHeader("If-Modified-Since","0");
xmlHttp.send(null);
}
function processRequestChange(){
// only if xmlHttp shows "complete"
if (xmlHttp.readyState == 4){
// only http 200 to process
if (window.location.href.indexOf("http")==-1 || xmlHttp.status == 200){
newsstring = xmlHttp.responseText;
//inject centent to tab-pane
shownews(requestType,newsstring);
}
}
}
function shownews(requestType,newsstring){
//<![CDATA[
responsecont = getObject(requestType+'_cnt');
responsecont.innerHTML = newsstring;
//]]>
}
function TabNews(tagid,x){
for (var i=1;i<=7;i+=2) {
if (i == x) {
getObject(tagid+i).className="tabactive"+i;
if(i!=1){
getObject(tagid+(i-1)).style.display="none";
if(i!=7){
getObject(tagid+(i+1)).style.display="none";
}
}
if(i==1){
getObject(tagid+"2").style.display="none";
}
try{
getnews(tagid,i);
}
catch(e){
alert(e);
}
}
else
{
getObject(tagid+i).className="";
if(i!=7){
getObject(tagid+(i+1)).style.display="block";
}
}
}
}
//-->
调用方法:
复制代码 代码如下:<li style="cursor:pointer" id="tab3" onclick="TabNews('tab',3)">最新折扣信息</li>
标签:
ajax实现标签导航
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“ajax实现标签导航”评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。