this.Dom = (document.createElement && document.appendChild && document.getElementsByTagName) ?true:false; this.Def = (this.IE||this.Dom); // most used browsers, for faster if loops this.ValidBrowser = this.NS6 || this.IE5 || this.IE55 || this.IE6; }Is=new Browser();if (!Is.ValidBrowser) alert("Internet browser is not valid version.\n We support netscape 6 higher or Microsoft Internet Explorer 5 or higher"); /////////////////////////////////////////////////////////////////////////////// // BaseApplet BaseApplet = function() { this.HtmlControl = null; // every applet must have HtmlControl element }
show一下啊!
就不行了,后来我把原来function的地方写上注释(////////////),写了81个"/",
就没事了,少一个都不行.代码我整理一下在贴出来.to manyou(我想我是海):
跟输入法有什么关系,我用紫光拼音.
html文件:
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Developer Studio">
<META HTTP-EQUIV="Content-Type" content="text/html; charset=gb_2312">
<TITLE>Document Title</TITLE></HEAD><script src="MtBase.js"></script>
<script src="ListView.js"></script><SCRIPT ID="pageControler" LANGUAGE="XML">
<SpeedBar bgColor="#CCCCCC" align="right">
<Html>一共有 %%V:RECORDNUM%% 条纪录</Html>
<Seperator outset="true" width="0px" />
<Html>第 <font id="PageNo">%%V:PAGENO%%</font> 页</Html>
<Html>共 <font id="PageNum">%%V:PAGENUM%%</font> 页</Html>
<Seperator outset="true" width="0px" />
<Button checkable="false" flat="true" id="nextPage" img="Img/NextPage.gif" text="下一页" txtPos="right" />
<Seperator outset="true" width="0px" />
<Button checkable="false" flat="true" id="prevPage" img="Img/PrevPage.gif" text="上一页" txtPos="right" />
<Seperator outset="true" width="0px" />
<Html><img src="Img/px1.gif" width="10" height="1px"/>跳到:<INPUT id="GotoPage" TYPE="text" size="2" value=""></INPUT>页</Html>
<Button checkable="false" flat="true" id="gotoPage" img="Img/go.gif" />
</SpeedBar>
</SCRIPT><body>
</body>
</html>其中的mtbase.js:
__MtBase_js__ = 1;///////////////////////////////////////////////////////////////////////////////
// Gather browser name and version informationfunction Browser()
{
var b = navigator.appName; if (!b)
alert('Unidentified browser.\nThis browser is not supported,'); if (b.indexOf('Netscape')!=-1)
this.b = "NS";
else if ((b=="Opera") || (navigator.userAgent.indexOf("Opera")>0))
this.b = "Opera";
else if (b=="Microsoft Internet Explorer")
this.b = "IE"; var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf("win")>-1)
this.platform="win32";
else if (ua.indexOf("mac")>-1)
this.platform="mac";
else
this.platform="other"; this.Version = navigator.appVersion;
this.V = parseInt(this.Version); this.NS = (this.b=="NS" && this.V>=4);
this.NS4 = (this.b=="NS" && this.V==4);
this.NS6 = (this.b=="NS" && this.V>=5); this.IE = (this.b=="IE" && this.V>=4);
this.IE4 = (this.Version.indexOf('MSIE 4')>0);
this.IE5 = (this.Version.indexOf('MSIE 5')>0);
this.IE55 = (this.Version.indexOf('MSIE 5.5')>0);
this.IE6 = (this.Version.indexOf('MSIE 6.0')>0); this.Opera = (this.b=="Opera");
this.Dom = (document.createElement && document.appendChild && document.getElementsByTagName)
?true:false;
this.Def = (this.IE||this.Dom); // most used browsers, for faster if loops this.ValidBrowser = this.NS6 || this.IE5 || this.IE55 || this.IE6;
}Is=new Browser();if (!Is.ValidBrowser)
alert("Internet browser is not valid version.\n We support netscape 6 higher or Microsoft Internet Explorer 5 or higher");
///////////////////////////////////////////////////////////////////////////////
// BaseApplet
BaseApplet = function()
{
this.HtmlControl = null; // every applet must have HtmlControl element
}
alert("please include MtBase.js");var __ListView_js__ = 1;var __FillStr = " ";if (Is.IE)
{
var split = null;
var pThis = null;
}
else
{
var CompDiv = document.createElement("div");
CompDiv.innerHTML = " ";
var CompText = CompDiv.innerText;
}///////////////////////////////////////////////////////////////////////////////
// ListViewListView = function()
{
this.BaseClass = BaseApplet;
this.BaseClass(); this.Checkable = true;
this.Sortable = false;
this.HeaderHeight = 22;
this.ItemHeight = 22;
this.HasVertLine = true;
this.HasHoriLine = true;
this.HeaderColor = "#D0D0D0";
this.CellColor = "transparent";
this.FocusColor = "#D8BFD8"; this.HeaderTextColor = "#000000";
this.SplitColor = "#778899";
this.LineColor = "#C0C0C0"; this.HtmlControl = document.createElement("div");
this.HtmlControl.style.border = "1px solid #778899"; this.Header = document.createElement("table");
this.Header.cellSpacing="0";
this.Header.cellPadding="0";
this.Header.style.tableLayout="fixed";
this.HeaderBox = document.createElement("div");
this.HeaderBox.style.overflow = "hidden";
var tr = this.Header.insertRow(0);
this.Header.Line = tr; this.Columns = new Array();
this.HideColumns = new Array();
this.SortColumn = null; this.List = document.createElement("table");
this.List.cellSpacing="0";
this.List.cellPadding="0";
this.List.style.tableLayout="fixed"; this.ListBox = document.createElement("div");
this.ListBox.style.overflow = "auto"; if (Is.NS)
{
this.ListBox.ListView = this;
this.ListBox.onscroll = function()
{
if (Is.NS)
{
this.ListView.Header.style.position = "relative";
this.ListView.Header.style.left = - this.scrollLeft + "px"; RepaintObj(this.ListView.HeaderBox);
}
else
this.ListView.HeaderBox.scrollLeft = this.scrollLeft;
}
}
else
{
pThis = this;
this.ListBox.eventId = "ListBox";
this.ListBox.onscroll = ListOnScroll;
} this.HeaderBox.insertAdjacentElement("beforeEnd", this.Header);
this.ListBox.insertAdjacentElement("beforeEnd", this.List); this.HtmlControl.insertAdjacentElement("beforeEnd", this.HeaderBox);
this.HtmlControl.insertAdjacentElement("beforeEnd", this.ListBox); this.FocusItem = null;
this.AfterInit = false;
}ListView.prototype = new BaseApplet;ListView.prototype.BaseIdx = function()
{
return this.Checkable? 2 : 0
}function __FillSplitImg(td, width)
{
var inImg = document.createElement("img");
inImg.src = "px" + width + ".gif";
inImg.border = "0";
inImg.style.width = width + "px";
inImg.style.height = width + "px";
td.insertAdjacentElement("beforeEnd", inImg);
}ListView.prototype.__CopyRow = function(dst, src)
{
if (this.Checkable)
dst.Check.checked = src.Check.checked;
dst.hideInfoArray = src.hideInfoArray;
for (var k=this.BaseIdx(); k<dst.childNodes.length-1; k+=2)
dst.childNodes[k].firstChild.innerHTML = src.childNodes[k].firstChild.innerHTML;
}ListView.prototype.__QPass = function(rows, start, end, iKey, bAsc)
{
var i=start;
var j=end; var rp = rows[start].cloneNode(true); if (this.Checkable)
{
rp.Check = new Object;
rp.Check.checked = rows[start].Check.checked;
} rp.hideInfoArray = rows[start].hideInfoArray;
var x = Parse(rows[start].cells[iKey].innerText);
if (bAsc)
{
while(i<j)
{
while(i<j && Parse(rows[j].cells[iKey].innerText)>=x)
j--;
this.__CopyRow(rows[i], rows[j]); // rows[i] = rows[j] while(i<j && Parse(rows[i].cells[iKey].innerText)<=x)
i++;
this.__CopyRow(rows[j], rows[i]); //rows[j] = rows[i];
}
}
else
{
while(i<j)
{
while(i<j && Parse(rows[j].cells[iKey].innerText)<=x)
j--;
this.__CopyRow(rows[i], rows[j]); // rows[i] = rows[j] while(i<j && Parse(rows[i].cells[iKey].innerText)>=x)
i++;
this.__CopyRow(rows[j], rows[i]); //rows[j] = rows[i];
}
} this.__CopyRow(rows[i], rp); //rows[i] = rp; return i;
}ListView.prototype.__QSortRows = function(rows, start, end, iKey, bAsc)
{
if (start<end)
{
var k = this.__QPass(rows, start, end, iKey, bAsc);
this.__QSortRows(rows, start, k-1, iKey, bAsc);
this.__QSortRows(rows, k+1, end, iKey, bAsc);
}
}ListView.prototype.SortByColumn = function(c, bAsc)
{
this.ClearFocusItem();
if (Is.NS)
{
c.ChangeSortMode(bAsc? 1 : 2);
}
else
{
if (c)
{
this.SortColumn = c;
c.SortMode = bAsc ? 1 : 2;
} ChangeSortMode();
} var iCol = c.cellIndex;
var rows = this.List.rows;
var nRow = rows.length; this.__QSortRows(rows, 0, nRow-1, iCol, bAsc);
}var SortModeImgs = new Array("SortNone.gif", "SortAsc.gif", "SortDsc.gif");
{
if (width == "0")
{
var hideObj = new Object;
hideObj.AttrName = attrName;
hideObj.name = text;
InsertArrayItem(this.HideColumns, this.HideColumns.length, hideObj);
return;
}
var nCol = this.Columns.length;
if (iPos<0 || iPos>nCol)
iPos = nCol;
if (nCol==0)
{
// insert tail filling
var fill = this.Header.Line.insertCell(0);
fill.className = "HeaderColumn";
fill.noWrap = "true";
fill.innerHTML = __FillStr;
fill.style.width = "100%";
fill.style.backgroundColor = this.HeaderColor; if (this.Checkable)
{
// insert "check all" column before the first real column inserting
var checkCol = this.Header.Line.insertCell(0);
checkCol.className = "HeaderColumn";
checkCol.noWrap = "true";
checkCol.style.width = "22px";
checkCol.style.height = this.HeaderHeight;
checkCol.style.backgroundColor = this.HeaderColor;
var ch = document.createElement("input");
ch.type = "checkbox";
checkCol.insertAdjacentElement("beforeEnd", ch);
this.Check = ch;
if (Is.NS)
{
ch.ListView = this;
ch.onclick = function()
{
var rows = this.ListView.List.rows;
var n = rows.length;
for (var i=0; i<n; i++)
rows[i].Check.checked = this.checked;
}
}
else
{
ch.eventId = "AllCheck";
ch.onclick = onCheckClick;
} var spl = this.Header.Line.insertCell(1);
spl.className = "HeaderSplitter";
spl.style.backgroundColor = this.SplitColor;
__FillSplitImg(spl, 1);
}
} var td = this.Header.Line.insertCell(this.BaseIdx() + iPos*2);
td.className = "HeaderColumn";
td.style.width = width;
td.style.height = this.HeaderHeight + "px";
td.style.backgroundColor = this.HeaderColor;
if (align)
td.style.textAlign = align; td.AttrName = attrName; div = document.createElement("div");
div.innerHTML = "<font color=" + this.HeaderTextColor + "><b> " + text + "</b>";
div.style.whiteSpace = "nowrap";
div.style.overflow = "hidden";
div.style.width = width; if (this.Sortable)
{
if (this.SortColumn == null)
{
td.SortMode = 1;
this.SortColumn = td;
}
else
{
td.SortMode = 0;
}
} if (this.Sortable)
{
var sortImg = document.createElement("img");
sortImg.src = SortModeImgs[td.SortMode];
sortImg.align = "absmiddle";
sortImg.style.width = "16";
sortImg.style.height = "16";
td.SortImg = sortImg; div.insertAdjacentElement("beforeEnd", sortImg);
} td.insertAdjacentElement("beforeEnd", div);
td.InDiv = div;
if (Is.NS)
{
td.ListView = this;
td.ChangeSortMode = function(smode)
{
this.SortMode = smode;
this.SortImg.src = SortModeImgs[smode];
} td.onmousedown = function()
{
this.className = "HeaderColumnPush";
CaptureMouseEvents(this);
return false;
}
td._onmouseup = function()
{
this.className = "HeaderColumn";
ReleaseMouseEvents();
return true;
} if (this.Sortable)
{
td.onclick = function()
{
if (this.ListView.SortColumn!=this)
{
if (this.ListView.SortColumn)
this.ListView.SortColumn.ChangeSortMode(0); this.ListView.SortByColumn(this, true);
this.ListView.SortColumn = this;
}
else
{
this.ListView.SortByColumn(this, this.SortMode==1 ? false: true);
}
}
}
}
else
{
td.eventId = "header";
td.onmousedown = headerMouseDown;
td._onmouseup = headerMouseUp; if (this.Sortable)
{
td.onclick = Sort;
}
} var spl = this.Header.Line.insertCell(this.BaseIdx() + iPos*2+1);
spl.className = "HeaderSplitter";
spl.style.backgroundColor = this.SplitColor;
spl.Column = td;
__FillSplitImg(spl, 2);
if (Is.NS)
{
spl.ListView = this; spl.onmousedown = function()
{
CaptureMouseEvents(this);
document.body.style.cursor = "move";
return false;
}
spl._onmouseup = function(ev)
{
if (Is.IE)
ev = event; // resize header column
var x = this.offsetLeft+1;
var w = this.Column.offsetWidth;
w += ev.clientX - x;
if (w<0)
w = 10; this.Column.style.width = w + "px";
this.Column.InDiv.style.width = w + "px"; // resize related virtical list cells
var rows = this.ListView.List.rows;
var iCol = this.Column.cellIndex;
var nRow = rows.length;
for(var i=0; i<nRow; i++)
{
rows[i].cells[iCol].style.width = w + "px";
rows[i].cells[iCol].InDiv.style.width = w + "px";
} this.ListView.Header.style.width = this.ListView.List.offsetWidth + 50 + "px"; if (Is.NS)
{
this.ListView.Header.style.position = "relative";
this.ListView.Header.style.left = - this.ListView.List.scrollLeft + "px"; RepaintObj(this.ListView.Header);
RepaintObj(this.ListView.List);
}
else
this.ListView.HeaderBox.scrollLeft = this.ListView.ListBox.scrollLeft; document.body.style.cursor = "auto";
ReleaseMouseEvents();
return false;
}
}
else
{
spl.eventId = "spl";
spl.onmousedown = splMouseDown;
spl._onmouseup = splMouseUp;
} InsertArrayItem(this.Columns, iPos, td);
}ListView.prototype.DeleteColumn = function(i)
{
if (this.SortColumn==this.Columns[i])
this.SortColumn = null;
this.Header.Line.deleteCell(i*2); // delete column
this.Header.Line.deleteCell(i*2); // delete splitter
}ListView.prototype.ClearFocusItem = function()
{
if (this.FocusItem)
{
var n = this.FocusItem.cells.length;
for (var i=0; i<n; i+=2)
this.FocusItem.cells[i].style.backgroundColor = this.CellColor;
this.FocusItem = null;
}
}ListView.prototype.SetFocusItem = function(item)
{
var n = item.cells.length;
for (var i=0; i<n; i+=2)
item.cells[i].style.backgroundColor = this.FocusColor;
this.FocusItem = item;
}ListView.prototype.InsertItem = function(iPos, xml)
{
var xmlNode;
if (typeof(xml)=="string")
xmlNode = GetXmlNodeByString(xml);
else
xmlNode = xml; var nRow = this.List.rows.length;
if (iPos<0 || iPos>nRow)
iPos = nRow; var row = this.List.insertRow(iPos);
row.hideInfoArray = new Array(); if (Is.NS)
{
row.ListView = this;
row.onclick = function()
{
if (this==this.ListView.FocusItem)
this.ListView.ClearFocusItem();
else
{
this.ListView.ClearFocusItem();
this.ListView.SetFocusItem(this);
}
}
}
else
{
row.eventId = "row";
row.onclick = rowOnClick;
} if (this.Checkable)
{
var checkCol = row.insertCell(0);
checkCol.className = Is.IE ? "ListCell_IE" : "ListCell_NS";
checkCol.noWrap = "true";
checkCol.style.width = this.ItemHeight;
checkCol.style.backgroundColor = this.CellColor;
if (!this.HasHoriLine)
checkCol.style.borderBottomStyle = "none";
charset=gb_2312-80",别人做的网页,没注意,可为什么以前没出问题呢?
唉,大家别犯我这样的毛病了.谢谢大家.