div悬浮框代码

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>无标题页</title>
<!-- 设置悬浮窗口 -->
<script type="text/javascript">
function scall(){
document.getElementById("topdiv").style.top=(document.documentElement.scrollTop)+150+"px";
document.getElementById("topdiv").style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth-document.getElementById("topdiv").offsetWidth)-60+"px";
}
window.onscroll=scall;
window.onresize=scall;
window.onload=scall;
</script>
<!--  计算剩余时间 -->
<script language="javascript">
var timer;
var examTimer=150*60;
var lastSecond,lastMinute;
timer=setInterval("showtime()",1000);
function showtime(){ 
examTimer--;
if (examTimer<=0){
    document.all.lastTime.innerHTML="0:00";
  clearInterval(timer);
  //调用自动提交试卷函数
  paperSubmit('',1);
}
else{
  lastSecond=examTimer % 60;
  lastMinute=(examTimer-lastSecond)/60;
  document.all.lastTime.innerHTML=lastMinute + ":" + (lastSecond<10?"0"+lastSecond:lastSecond);
}
}
function paperSubmit(strNO,isAuto){
  if (isAuto==1){
  alert("你的答题时间已到,请按确认进行交卷!");
}
else{
  if (!confirm("是否确定交卷呢?"))return;
}
}
</script>
<style type="text/css">
<!--
悬浮窗口 -->#topdiv {
position: absolute;
width: 87px;
height: 116px;
z-index: 1;
text-align: center;
}

.hot {
font-weight: normal;
color: #002899;
margin-left: 10px;
font-size: 12px;
font-weight: bold;
}

.red {
color: #FF0000;
}
</style>
</head>
<body>
  <div align="center">
   <center>
    <table width="770px" border="0" cellpadding="0" cellspacing="0"
     bgcolor="#F4F4F4">
     <tr>
      <td height="3000px" valign="top"></td>
     </tr>
    </table>
   </center>
  </div>
  <div id="topdiv"
   style="POSITION: absolute; z-index: 1000; background-image: url(images/float.gif);">
   <table width="87px" border="0" cellpadding="0" cellspacing="0">
    <tr>
     <td height="30" align="center" valign="bottom" class="hot">
      答题剩余时间
     </td>
    </tr>
    <tr>
     <td height="40px" align="center" class="red">
      <table width="70" border="0" cellspacing="0" cellpadding="0">
       <tr>
        <td align="center" bgcolor="#FFFFFF">
         <label id="lastTime">
          150:00
         </label>
        </td>
       </tr>
      </table>
     </td>
    </tr>
    <tr>
     <td align="center" height="46px">
      <input type="image" src="images/jj-button.gif" width="67"
       height="24" onclick="paperSubmit('1','')" />
     </td>
    </tr>
   </table>
  </div>
</body>
</html>

你可能感兴趣的:(html,XHTML)