浮動層顯示JS

來源:互聯網
上載者:User
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 style="POSITION: absolute; Z-INDEX: 1"></DIV>
            <SCRIPT language=javascript src="xxx.js"></SCRIPT>

樣本地址:http://www.xrss.cn/fjcity.asp



相關文章

Cloud Intelligence Leading the Digital Future

Alibaba Cloud ACtivate Online Conference, Nov. 20th & 21st, 2019 (UTC+08)

Register Now >

Starter Package

SSD Cloud server and data transfer for only $2.50 a month

Get Started >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。