javascript类功能代码集
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
/*
功能:鼠标放置不同DIV时显示不同的底色/底图,并还原先前图
lastDiv上一次作用的对象
initClass非作用对象的样式表
currentClass当前作用对象的样式表
lastContentDiv上一次作用对象对应的内容
*/
var _DivBgChange = function(lastDiv,initClass,currentClass,lastContentDiv){
this.init = initClass;
this.current = currentClass;
this.lastDiv = lastDiv;
this.lastContentDiv = lastContentDiv;
}
_DivBgChange.prototype = {
/*二种形式相互变换*/
OverA : function(currentDiv,currentContentDiv){
MM_findObj(this.lastDiv).className = this.init;
MM_findObj(this.lastContentDiv).style.display = "none";
MM_findObj(currentDiv).className = this.current;
MM_findObj(currentContentDiv).style.display = "";
this.lastDiv = currentDiv;
this.lastContentDiv = currentContentDiv;
},
/*四种形式相互变换*/
OverB : function(currentDiv,otherDiv,currentContentDiv,currentImg,otherImg){
MM_findObj(currentDiv).style.background = "url(" + currentImg + ")";
MM_findObj(this.lastContentDiv).style.display = "none";
MM_findObj(otherDiv).style.background = "url(" + otherImg + ")";
MM_findObj(currentContentDiv).style.display = "";
this.lastDiv = currentDiv;
this.lastContentDiv = currentContentDiv;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
/*
功能:动态广告
*/
var _Ad1 = function(W,H){
this.browser = window.ActiveXObject ? "IE" : "OTHER";
this.focus_width = W;
this.focus_height = H;
this.text_height = 0;
this.swf_height = this.focus_height + this.text_height;
this.texts = "";
this.pics = "";
this.links = "";
}
_Ad1.prototype = {
AdShow : function(X){
var xmlDoc = loadXML("/editor/xml/" + X + ".xml");
var root = xmlDoc.getElementsByTagName("NewDataSet")[0];
var tables = root.getElementsByTagName("table");
var EndStr = "";
for(var i = 0;i < tables.length;i++)
{
i == tables.length-1 ? EndStr = "" : EndStr = "|";
if(this.browser == "IE")
{
this.pics += tables[i].childNodes[0].firstChild.nodeValue + EndStr;
this.links += tables[i].childNodes[1].firstChild.nodeValue + EndStr;
}
else
{
this.pics += tables[i].childNodes[1].firstChild.nodeValue + EndStr;
this.links += tables[i].childNodes[3].firstChild.nodeValue + EndStr;
}
}
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ this.focus_width +'" height="'+ this.swf_height +'">');
document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="/ad/focus.swf"> <param name="quality" value="high"><param name="bgcolor" value="#ffffff">');
document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
document.write('<param name="FlashVars" value="pics='+this.pics+'&links='+this.links+'&texts='+this.texts+'&borderwidth='+this.focus_width+'&borderheight='+this.focus_height+'&textheight='+this.text_height+'">');
document.write('<embed src="/ad/focus.swf" wmode="opaque" FlashVars="pics='+this.pics+'&links='+this.links+'&texts='+this.texts+'&borderwidth='+this.focus_width+'&borderheight='+this.focus_height+'&textheight='+this.text_height+'" menu="false" bgcolor="#ffffff" quality="high" width="'+ this.focus_width +'" height="'+ this.swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write('</object>');
}
}