📄 eforumad.js
字号:
//广告项对象
function getBrowserObj(){
var browserObj;
if (document.documentElement) {
browserObj = document.documentElement;
}
else if (document.body) {
browserObj = document.body;
}
return browserObj;
}
function ADItemObj(){
this.id = 0;
this.type = 1;
this.resHeight = 100 ;
this.resWidth = 100 ;
this.hint = "" ;
this.resURL = "" ;
this.linkURL = "";
this.power =1 ;
this.transparent = "0";
this.getHtml = getADItemHTML;
}
//产生显示使用的HTML
function getADItemHTML(){
var str = "";
var name = "ad_" + this.id;
switch(this.type) {
case 1: //图片
str = "<A TARGET='_blank' HREF='"+this.linkURL+"'><IMG ID='"+name+"' NAME='"+name+"' BORDER=0 HEIGHT=" ;
str+= this.resHeight + " WIDTH="+ this.resWidth + " SRC='" + this.resURL + "' title='" + this.hint + "' ALT='" +this.hint+ "'></A>"
break;
case 2: //flash
str ="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' ";
str+=" name='"+ name +"' id='"+name+"' width='" + this.resWidth + "' height='"+ this.resHeight+ "'>";
str+="<param name='movie' value='"+this.resURL+ "'>";
if(this.transparent == "1"){
str+="<param name='wmode' value='Transparent'>";
}
str+="<param name='quality' value='autohigh'>";
str+="<embed name='"+ name +" id='"+name+"' width='" + this.resWidth + "' height='"+ this.resHeight+ "' src='"+this.resURL+"'";
if(this.transparent == "1"){
str+=" wmode='Transparent'" ;
}
str+=" quality='autohigh' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash'></embed>";
str+="</object>" ;
break;
case 3: //html文本;
case 4: //代码;
str = this.resURL;
break;
case 5: //页面
str ="<IFRAME FRAMEBORDER=0 SCROLLING=NO FRAMESPACING=0 MAGINWIDTH=0 MARGINHEIGHT=0 HEIGHT=";
str+= this.resHeight + " WIDTH="+ this.resWidth + " SRC='" + this.resURL +"'></IFRAME>";
}
//document.write(str);
return str;
}
//广告浮动块
function ADFloatDIV(id) {
this.ID = id;
this.divName="";
this.status = true;
this.virgin = true;
this.adItems = new Array();
this.currentAD = null;
this.htmlDIV = null;
this.floatType = 1;
this.divWidth = 100;
this.divHeight = 100;
this.left = -1;
this.top = -1;
this.dx = 2 *( Math.random() > 0.5 ? 1 :-1);
this.dy = 1 *( Math.random() > 0.5 ? 1 :-1);
this.counter=0;
this.timer = null;
this.step = 1 ;
this.rate = 10 ;
this.delay = 3000;
this.setADItem = Float_setADItem;
this.adStart = adStart;
this.showDIV= Float_showDIV;
this.floatDIV = Float_floatDIV;
this.pauseMove=Float_pauseMove;
this.continueMove=Float_continueMove;
this.divInvisible = Float_invisible;
this.getCurrentAD = getRandomObj;
this.initDiv = FLoat_InitDiv;
this.popWindow = pop_window;
}
function adStart() {
if ( this.floatType <= 10 ) {
this.showDIV();
} else if ( this.floatType > 10 ) {
this.popWindow();
}
}
function FLoat_InitDiv() {
if( this.virgin == false ) return;
this.virgin = false;
var browserObj = getBrowserObj();
//匀速漂移 ---变速漂移
if ( this.floatType == 1 || this.floatType == 2 || this.floatType ==3 || this.floatType == 4) {
if( this.left < 0 ) {
this.left = 500 + 500 * Math.random() * ( Math.random() > 0.5 ? 1 :-1) ;
}
if( this.top < 0 ) {
this.top = 300 + 300 * Math.random() * ( Math.random() > 0.5 ? 1 :-1) ;
}
//
//中央投影,随屏滚动。
} else if (this.floatType== 5 || this.floatType == 6 || this.floatType == 7 || this.floatType == 8 || this.floatType == 9) {
if( this.left == -1 ) {
this.left = ( browserObj.offsetWidth-this.divWidth -22) / 2 ;
} else if( this.left == -2 ) {
this.left = browserObj.offsetWidth - this.divWidth - 22 ;
}
if( this.top == -1 ) {
this.top = ( browserObj.offsetHeight-this.divHeight - this.dy) / 2 ;
} else if (this.top == -2 ) {
this.top = browserObj.offsetHeight - this.divHeight - this.dy*2 ;
}
}
if (this.left > (browserObj.offsetWidth - this.divWidth -22)) {
this.left = (browserObj.offsetWidth - this.divWidth -22) / window.screen.width * this.left;
if (this.left > (browserObj.offsetWidth - this.divWidth -22)) {
this.left = (browserObj.offsetWidth - this.divWidth -22) ;
}
}
if (this.top > ( browserObj.offsetHeight - this.divHeight - this.dy*2)) {
this.top = ( browserObj.offsetHeight - this.divHeight - this.dy*2 ) / window.screen.width * this.top ;
if (this.top > ( browserObj.offsetHeight - this.divHeight - this.dy*2)) {
this.top = ( browserObj.offsetHeight - this.divHeight - this.dy*2 ) ;
}
}
}
//显示DIV,并在屏幕浮动。
function Float_floatDIV() {
var browserObj = getBrowserObj();
screenX=browserObj.scrollLeft;
screenY=browserObj.scrollTop;
screenW=browserObj.clientWidth-this.divWidth - 22;
screenH=browserObj.clientHeight-this.divHeight - this.dy*2 ;
this.initDiv();
var theLeft , theTop ;
//匀速漂移
if ( this.floatType == 1 ) {
theLeft = this.left + this.dx * this.step
theTop = this.top + this.dy * this.step ;
if( ( theLeft >= screenW && this.dx> 0 ) || ( theLeft <=0 && this.dx <0 )) this.dx= -1 * this.dx ;
if( ( theTop >= screenH && this.dy >0 ) || ( theTop <= 0 && this.dy <0 )) this.dy= -1 * this.dy ;
//变速漂移
} else if ( this.floatType == 2) {
if( this.counter >= ( 200 / this.rate )) {
this.dx = ( this.dx > 0 ? 1 : -1 ) * Math.random() * 5;
this.dy = ( this.dy > 0 ? 1 : -1 ) * Math.random() * 5 ;
this.counter = 0 ;
}
this.counter+=1 ;
theLeft = this.left ;
theTop = this.top + this.dy * this.step ;
if( ( theLeft >= screenW && this.dx> 0 ) || ( theLeft <=0 && this.dx <0 )) this.dx= -1 * this.dx ;
if( ( theTop >= screenH && this.dy >0 ) || ( theTop <= 0 && this.dy <0 )) this.dy= -1 * this.dy ;
//垂直上下
} else if( this.floatType == 3 ) {
this.dx=0;
theLeft = this.left + this.dx * this.step
theTop = this.top + this.dy * this.step ;
if( ( theLeft >= screenW ) || ( theLeft <=0 )) { this.left = this.left + this.currentAD.resWidth; }
if( ( theTop >= screenH && this.dy >0 ) || ( theTop <= 0 && this.dy <0 )) this.dy= -1 * this.dy ;
//水平滚动。
} else if( this.floatType ==4 ) {
this.dy=0;
theLeft = this.left + this.dx * this.step
theTop = this.top + this.dy * this.step ;
//if( ( theLeft >= screenW ) || ( theLeft <=0 )) { this.left = this.left + this.currentAD.resWidth; }
if( ( theLeft >= screenW && this.dx >0 ) || ( theTop <= 0 && this.dy <0 )) this.dx= -1 * this.dx ;
//随屏滚动_中间。
} else if( this.floatType== 5 ) {
//this.dx = 0;
//this.dy = 0;
//this.left = screenW ;
//this.top = screenH ;
this.left = 0;
this.top = (screenH / 2);
//中央投影
} else if(this.floatType== 7 ) {
this.left = 0;
this.top = (screenH / 2);
//随屏滚动_右边_中间。
} else if(this.floatType== 8 ) {
this.left = screenW;
this.top = (screenH / 2);
// 屏幕右下角.
}else if(this.floatType== 9 ) {
this.left = screenW;
this.top = screenH - 15;
} else if (this.floatType == 6) {
this.htmlDIV.style.left= this.left;
this.htmlDIV.style.top= this.top;
this.htmlDIV.timer=setTimeout( this.ID +".divInvisible()",this.delay);
return ;
//随屏滚动_左边_中间。
}
this.left = this.left + this.dx * this.step ;
this.top = this.top + this.dy * this.step ;
this.htmlDIV.style.left = this.left + screenX + "px";
this.htmlDIV.style.top=this.top + screenY + "px";
var delay = 80 / this.rate;
this.htmlDIV.timer=setTimeout( this.ID +".floatDIV()",delay);
}
//得到整个块的显示使用的HTML。
function Float_showDIV() {
this.currentAD = this.getCurrentAD(this.adItems);
this.divHeight = this.currentAD.resHeight;
this.divWidth = this.currentAD.resWidth ;
//为空不显示。
if( this.currentAD == null || this.currentAD=="") return ;
this.divName = "ADF_" + this.ID;
this.divHeight = this.divHeight+22;
var str = "<DIV id='"+ this.divName + "' onMouseOver='" + this.ID+".pauseMove()' onMouseOut='" +this.ID+ ".continueMove()" ;
str += "' STYLE='position:absolute; visibility:visible; z-index:1; width:" ;
str += this.divWidth + "px; height:" + this.divHeight + "px; left:" + this.left+ ";top:" + this.top + "'>";
str += this.currentAD.getHtml();
str += "<DIV STYLE='width:100%;background-color:#ECECEC;text-align:right;'><span STYLE='font-size:12px; line-height:1.5;' ><A onclick='"+this.ID+".divInvisible();' style='text-decoration:none;color:#000;cursor:pointer'>关闭</A> </span>";
str +="</DIV></DIV>";
document.write(str);
this.htmlDIV = document.getElementById(this.divName);
this.floatDIV();
}
function Float_pauseMove() {
clearTimeout(this.htmlDIV.timer)
}
function Float_continueMove() {
if( this.status ) this.floatDIV();
}
//设置当前广告项。
function Float_setADItem(ItemObj) {
var thisLine = this.adItems.length;
this.adItems[thisLine] = new Array( ItemObj , ItemObj.power);
}
// 去掉显示。
function Float_invisible() {
clearTimeout(this.htmlDIV.timer)
this.htmlDIV.style.visibility="hidden";
this.status = false;
}
//弹出窗口。
function pop_window() {
}
function getRandomObj( array ){
var totalPower = 0 ;
var start = 0 ;
for( ii = 0 ; ii < array.length ; ii++) {
totalPower += array[ii][1];
array[ii][2] = start;
array[ii][3] = start + array[ii][1];
start = array[ii][3];
}
var theSelected = Math.random() * totalPower ;
var counter = 0 ;
for( ii = 0 ; ii< array.length ; ii++ ) {
if( theSelected > array[ii][2] && theSelected < array[ii][3] ) {
return array[ii][0];
}
} //end for
}
//静态广告信息块
function staticADDIV(id) {
this.ID = id;
this.adItems = new Array();
this.currentAD = null;
this.setADItem = static_setADItem;
this.setHtml = positionADHTML;
this.getCurrentAD = getRandomObj;
}
function positionADHTML(divName) {
var divObj = document.getElementById( divName);
this.currentAD = this.getCurrentAD(this.adItems);
var str = this.currentAD.getHtml();
//alert(str);
divObj.innerHTML = str;
}
//设置当前广告项。
function static_setADItem(ItemObj) {
var thisLine = this.adItems.length;
this.adItems[thisLine] = new Array( ItemObj , ItemObj.power);
}
//多图片变化显示;
function ADPicsItemObj(){
this.pigSrcs=new Array();
this.picLink=new Array();
this.picHint=new Array();
this.adNumPic=0;
this.target="_blank";
this.imgId = "";
}
//下一个图片
function picItemNextAd(adPicsItemObj){
if(adPicsItemObj.adNumPic<adPicsItemObj.pigSrcs.length-1){
adPicsItemObj.adNumPic++ ;
}else{
adPicsItemObj.adNumPic=0;
}
picItemSet(adPicsItemObj);
document.getElementById(adPicsItemObj.imgId).src=adPicsItemObj.pigSrcs[adPicsItemObj.adNumPic];
picItemPlayCo(adPicsItemObj);
}
function picItemSet(adPicsItemObj){
document.getElementById(adPicsItemObj.imgId).filters.revealTrans.Transition=Math.floor(Math.random()*23);
document.getElementById(adPicsItemObj.imgId).filters.revealTrans.apply();
}
function picItemPlayCo(adPicsItemObj){
document.getElementById(adPicsItemObj.imgId).filters.revealTrans.play();
}
//图片链接;
function picItemLinkUrl(adPicsItemObj){
jumpUrl=adPicsItemObj.picLink[adPicsItemObj.adNumPic];
if (jumpUrl != ''){
if (adPicsItemObj.target == '_blank'){
window.open(jumpUrl,'_blank');
}else{
location.href=jumpUrl;
}
}
}
//在浏览器底部状态栏显示Msg;
function picImteListMsg(adPicsItemObj){
status=adPicsItemObj.picHint[adPicsItemObj.adNumPic];
document.returnValue = true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -