I haven't tested the specific content. For reference only
Code
JS code part. The js part of the code is relatively simple. The most important ones are the XML operation functions
//JavaScript
function bindNew(index)
{
var List = new Array();
List = showPage(index);
var listul = "
"
for( var i=0 ; i < List.length ; i )
{
//document.getElementById("listTb").innerHTML = List[i] "";
listul = "- " List[i] "
";
}
listul = "
";
document.getElementById("listTb").innerHTML = listul;
document.getElementById("refer").innerHTML = "";
var tc = rtnPageCount();
for( var i=1 ; i<=tc ; i )
{
//
document.getElementById("refer").innerHTML = "
" i "
";
}
}
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.resolveExternals = false;
xmlDoc.load("News.xml");
// 返回固定 ID 的新闻
function findNew(newid)
{
var Domelement = xmlDoc.documentElement;
alert(Domelement);
}
// 返回分页后的新闻标题连接
var pageSize = 40;
function showPage(pageIndex)
{
var Alltt = new Array();
Alltt = AlltitleLink();
var rtLinks = new Array();
/*未完成部分*/
try
{
for( var i=0 ; i< pageSize && (pageSize*(pageIndex-1) i)
{
rtLinks[i] = Alltt[pageSize*(pageIndex-1) i];
}
}
catch(e)
{ alert("showPage() 方法出错 !"); }
return rtLinks;
}
//返分页后的页数
function rtnPageCount()
{
var countx = getCount();
if(countx%pageSize == 0)
{
return countx/pageSize ;
}
else
{
return countx/pageSize 1 ;
}
}
//返回新闻条数
function getCount()
{
var NewRoot = xmlDoc.documentElement;
var AllNews = NewRoot.childNodes;
return AllNews.length;
}
//返回固定条数的新闻标题连接
function returnNews(count)
{
var titles = new Array();
var j = 0;
NewRoot = xmlDoc.documentElement;
allNews = NewRoot.childNodes;
for( var i=0 ; i{
if(i >= allNews.lenth)
{
titles[j] = "" allNews[i].getArrtibute("name") "";
j ;
}
}
return titles;
}
//发回所有新闻 标题的超连接
function AlltitleLink()
{
var allttLink = new Array();
var NewRoot = xmlDoc.documentElement ;
var allNews = NewRoot.childNodes;
for( var i=0 ; i{
var context = allNews[i];
allttLink[i] = "" context.getAttribute("time") " : " context.getAttribute("name") "";
}
return allttLink;
}