java/js 右下腳浮動小視窗,慢慢上升,類似於廣告視窗

來源:互聯網
上載者:User

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script language="JavaScript">
<!--
var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer;
function getMsg()
{
divHeight = parseInt(document.getElementById("eMeng").offsetHeight,10);
divWidth = parseInt(document.getElementById("eMeng").offsetWidth,10);
docWidth = document.body.clientWidth;
docHeight = document.body.clientHeight;
document.getElementById("eMeng").style.top = docHeight + parseInt(document.body.scrollTop,10) + 5;
document.getElementById("eMeng").style.left = docWidth + parseInt(document.body.scrollLeft,10) - divWidth ;
document.getElementById("eMeng").style.visibility="visible";
objTimer = window.setInterval("moveDiv()",10);
}

//右下腳小視窗慢慢上升
function moveDiv(){
if(parseInt(document.getElementById("eMeng").style.top,10) < (docHeight - divHeight + parseInt(document.body.scrollTop,10)))
{
window.clearInterval(objTimer);
return;
}
divTop = parseInt(document.getElementById("eMeng").style.top,10);
document.getElementById("eMeng").style.top = divTop - 2;
}

function resizeDiv()
{
divHeight = parseInt(document.getElementById("eMeng").offsetHeight,10);
divWidth = parseInt(document.getElementById("eMeng").offsetWidth,10);
docWidth = document.body.clientWidth;
docHeight = document.body.clientHeight;
document.getElementById("eMeng").style.top = docHeight + parseInt(document.body.scrollTop,10) - divHeight ;
document.getElementById("eMeng").style.left = docWidth + parseInt(document.body.scrollLeft,10) - divWidth;
}

function closeDiv()
{
document.getElementById('eMeng').style.visibility="hidden";
if(objTimer) window.clearInterval(objTimer);
}


window.onload = getMsg;
window.onresize = resizeDiv;
window.onscroll = resizeDiv;
-->
</script>
<body style="font-size:12px;">
<div id="eMeng" style="border:1px solid #7788CC;visibility:hidden;position:absolute;top:0px;left:0px;height:150px;width:260px;">
  <div style="background-color:#7788FF;width:260px;height:20px;">
    <div style="cursor:hand;font-size:12px;font-weight:bold;text-align:right;" onClick="closeDiv()">×</div>
  </div>
  <!--設計浮動視窗-->
  <div style="border:3px solid #BBCCFF;background-color:#D5E7FD;width:260px;height:130px;">
  <center>
      <div id="myform">
            這裡設計想要的表單
         <form name="myform" method="post">
            <p>姓名:<input type="text"/></p>
            <p>QQ: <input type="text"/></p>
            <p>電話: <input type="text"/></p>
             <p> <input type="submit" value="提交"/></p>
         </form>
     
      </div>
  </center>
  </div>
</div>
</body>
</html>

聯繫我們

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

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

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.