【www.gdgbn.com--浏览器】

兼容多浏览器右下角浮动广告js代码

var opp;
var wh;
var hi;

var dialogright = function(title,content,height,width)
{
 var my = this;
 this._title = title;
 this._content = content;
 this._height = height;
 hi = height;
 this._width = width;
 wh = width;
 this._time = 5;
 this._timer = null;
 this.div_name = "";
 this.show = function()
 {
  var date = new date();
  var divname  = "";
  divname += new string(date.getmilliseconds());
  divname += math.random(0)*10;
  divname = divname.replace(".","_");
  my.div_name = divname;
  opp = document.createelement("div");
  opp.id = divname;
  opp.style.position = "absolute";
  //opp.style.border = "solid 1px #000";
  opp.style.width = my._width + "px";
  opp.style.height = 10 + "px"//慢慢延伸到my._height高度;
  opp.style.overflow = "hidden";
  opp.style.zindex = 9999;
 
  var left = document.documentelement.clientwidth - my._width ;
  var top = document.documentelement.scrolltop + document.documentelement.clientheight - 10;
  opp.style.left = left - 5 + "px";
  opp.style.top  = top  + "px";
 
 
  var html = "网页特效:;" onclick="closeo教程pp("" + divname + "")" >>";
  html += "asp教程x?id=8" target="_blank">"
 
   /*
  var html = ""
  html += ">";
  html += " ";
*/
//opp.innerhtml = "";//隐藏
opp.innerhtml = html;//显示
  if(dialogright.prototype.alldivname == "" || dialogright.prototype.alldivname == undefined)
    dialogright.prototype.alldivname = divname;
  else
    dialogright.prototype.alldivname += "|" + divname;
  document.body.appendchild(opp);
  my.render();
 
 }

 this.render = function()
 {
  if(my._timer == null)
  {
    my._timer = setinterval(my.expand,my._time);
  }
 }
 this.expand = function()
 {
  var _obj = document.getelementbyid(my.div_name);
  var tp = _obj.style.top;
  if(window.navigator.appname == "netscape" ? parseint(tp.replace("px","")) >= document.documentelement.clientheight - my._height : _obj.clientheight <= my._height)
  {
   var hi = _obj.style.height;
   hi = parseint(hi.replace("px",""));
   tp = parseint(tp.replace("px",""));
   _obj.style.height = hi + 2;
   _obj.style.top = (tp - 2) + "px";
  }
  else
  {
   clearinterval(my._timer);
  }
 }
}
dialogright.prototype.removedivname = function(divname)
{
  var divname = dialogright.prototype.alldivname;
  divname = divname.replace(divname,"");
  divname = divname.replace("|"+divname ,"");
  dialogright.prototype.alldivname = divname;
}
function closeopp(divname)
{
 var obj = document.getelementbyid(divname);
 document.body.removechild(obj);
 dialogright.prototype.removedivname(divname);
}

window.onscroll = function ()//滚动时保持原相对位置
{
 var divnames = dialogright.prototype.alldivname == undefined ? "" : dialogright.prototype.alldivname;
 if(divnames != "")
 {
  var divname = divnames.split("|");
  for(var i=0;i   {
   var obj = document.getelementbyid(divname[i]);
   if(obj != null){
      if(window.navigator.appname == "netscape")
        obj.style.top =  document.documentelement.scrolltop + document.documentelement.clientheight - hi + "px";
      else
       obj.style.top =  document.documentelement.scrolltop + document.documentelement.clientheight - obj.clientheight + "px";
   }
  }
 }
}

  function kleft(){
     var left = document.documentelement.clientwidth - wh ;
     opp.style.left = left - 5 + "px";
     //alert(left);
  }

var test2 = new dialogright("","",240,295);
test2.show();
setinterval("kleft()",100);

本文来源:http://www.gdgbn.com/bangongshuma/29326/