浮动层显示JS

80酷酷网    80kuku.com

  js|浮动|浮动层|显示

var offsetx = -120;
var offsety = -100;
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false

if (ie4) {
 if (navigator.userAgent.indexOf('MSIE 5')>0) {
  ie5 = true;
 } else {
  ie5 = false; }
} else {
 ie5 = false;
}

var x = 0;
var y = 0;
var para = 0;
var sw = 0;
var cnt = 0;
var dir = 1;
var tr=1;
if ( (ns4) || (ie4) ) {
 if (ns4) over = document.overDiv
 if (ie4) over = overDiv.style
 document.onmousemove = mouseMove
 if (ns4) document.captureEvents(Event.MOUSEMOVE)
}
function hide() {
 if ( cnt >= 1 ) { sw = 0 };
 if ( (ns4) || (ie4) ) {
  if ( sw == 0 ) {
   para = 0;
   hideObject(over);
  } else {
   cnt++;
  }
 }
}

function show(txt) {
 layerWrite(txt); 
 disp();
}
function layerWrite(txt) {
        if (ns4) {
                var lyr = document.overDiv.document
                lyr.write(txt)
                lyr.close()
        }
        else if (ie4) document.all["overDiv"].innerHTML = txt
  if (tr) {  }
}
function disp() {
 if ( (ns4) || (ie4) ) {
  if (para == 0)  {// Right   
    moveTo(over,x+offsetx,y+offsety);
   }   
   showObject(over);
   para = 1;
  }
 }

function mouseMove(e) {
 if (ns4) {x=e.pageX; y=e.pageY;}
 if (ie4) {x=event.x; y=event.y;}
 if (ie5) {x=event.x+document.body.scrollLeft; y=event.y+document.body.scrollTop;}
 if (para) {  
   moveTo(over,x+offsetx,y+offsety);
  }
 }
function cClick() {
 hideObject(over);
 sw=0;
}

// Make an object visible
function showObject(obj) {
        if (ns4) obj.visibility = "show"
        else if (ie4) obj.visibility = "visible"
}

// Hides an object
function hideObject(obj) {
        if (ns4) obj.visibility = "hide"
        else if (ie4) obj.visibility = "hidden"
}

// Move a layer
function moveTo(obj,xL,yL) {
        obj.left = xL
        obj.top = yL
}

另外,在要显示的页面中适当位置添加:
            <DIV id=overDiv absolute; Z-INDEX: 1"></DIV>
            <SCRIPT language=javascript src="xxx.js"></SCRIPT>

示例地址:http://www.xrss.cn/fjcity.asp



分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: