<%@ page language="java" import="java.util.*" pageEncoding="GB2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!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">
<html>
<head>
<base href="<%=basePath%>">
<script language="javascript">
var nMS=1000*60;
function GetRTime(){
var nH=Math.floor(nMS/(1000*60*60)) % 24;
var nM=Math.floor(nMS/(1000*60)) % 60;
var nS=Math.floor(nMS/1000) % 60;
document.getElementById("Javascript.Div4").innerHTML="还剩余"+nH+"小时"+nM+"分钟"+nS+"秒";
nMS=nMS-1000;
if(nH==0&nM==5&nS==0)
{
alert("还有最后五分钟!");
}
if(nH==0&nM==0&nS==0){
var paperForm=document.getElementById("ListForm");
paperForm.submit();
alert("考试时间到,试卷自动提交!");
}
setTimeout("GetRTime()",1000);
}
</script>
</head>
<style>
.div{
position: absolute;
border: 2px solid red;
background-color: #EFEFEF;
line-height:90px;
font-size:12px;
z-index:1000;
}
</style>
<body>
<div id="Javascript.Div4" class="div" style="width: 240px; height:90px" align="center">time</div>
<SCRIPT LANGUAGE="JavaScript">
function sc4(){
document.getElementById("Javascript.Div4").style.top=(document.documentElement.scrollTop)+"px";
document.getElementById("Javascript.Div4").style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth-document.getElementById("Javascript.Div4").offsetWidth)+"px";
}
function callall(){
sc4();
GetRTime();
}
window.onscroll=sc4;
window.onresize=sc4;
window.onload=callall;
//
</SCRIPT>
<form name="ListForm" action="car.jsp" method="post">
<input type="text" value="" name="name">
<input type="submit" value="提交" name="">
</form>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</body>
</html>如果将自己写的代码拷贝到这个里面就不出错但是如果将代码
<script language="javascript">
function sc4(){
document.getElementById("Javascript.Div4").style.top=(document.documentElement.scrollTop)+"px";
document.getElementById("Javascript.Div4").style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth-document.getElementById("Javascript.Div4").offsetWidth)+"px";
}
</script>
拷贝到别处就连 div层也不显示了.
为什么,名字什么的都正确
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!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">
<html>
<head>
<base href="<%=basePath%>">
<script language="javascript">
var nMS=1000*60;
function GetRTime(){
var nH=Math.floor(nMS/(1000*60*60)) % 24;
var nM=Math.floor(nMS/(1000*60)) % 60;
var nS=Math.floor(nMS/1000) % 60;
document.getElementById("Javascript.Div4").innerHTML="还剩余"+nH+"小时"+nM+"分钟"+nS+"秒";
nMS=nMS-1000;
if(nH==0&nM==5&nS==0)
{
alert("还有最后五分钟!");
}
if(nH==0&nM==0&nS==0){
var paperForm=document.getElementById("ListForm");
paperForm.submit();
alert("考试时间到,试卷自动提交!");
}
setTimeout("GetRTime()",1000);
}
</script>
</head>
<style>
.div{
position: absolute;
border: 2px solid red;
background-color: #EFEFEF;
line-height:90px;
font-size:12px;
z-index:1000;
}
</style>
<body>
<div id="Javascript.Div4" class="div" style="width: 240px; height:90px" align="center">time</div>
<SCRIPT LANGUAGE="JavaScript">
function sc4(){
document.getElementById("Javascript.Div4").style.top=(document.documentElement.scrollTop)+"px";
document.getElementById("Javascript.Div4").style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth-document.getElementById("Javascript.Div4").offsetWidth)+"px";
}
function callall(){
sc4();
GetRTime();
}
window.onscroll=sc4;
window.onresize=sc4;
window.onload=callall;
//
</SCRIPT>
<form name="ListForm" action="car.jsp" method="post">
<input type="text" value="" name="name">
<input type="submit" value="提交" name="">
</form>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</body>
</html>如果将自己写的代码拷贝到这个里面就不出错但是如果将代码
<script language="javascript">
function sc4(){
document.getElementById("Javascript.Div4").style.top=(document.documentElement.scrollTop)+"px";
document.getElementById("Javascript.Div4").style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth-document.getElementById("Javascript.Div4").offsetWidth)+"px";
}
</script>
拷贝到别处就连 div层也不显示了.
为什么,名字什么的都正确
position: absolute;
border: 2px solid red;
background-color: #EFEFEF;
line-height:90px;
font-size:12px;
z-index:1000;
}
这段代码copy过去。马上就好了啊!
var nMS=1000*60;
function GetRTime(){
var nH=Math.floor(nMS/(1000*60*60)) % 24;
var nM=Math.floor(nMS/(1000*60)) % 60;
var nS=Math.floor(nMS/1000) % 60;
document.getElementById("Javascript.Div4").innerHTML="还剩余"+nH+"小时"+nM+"分钟"+nS+"秒";
nMS=nMS-1000;
if(nH==0&nM==5&nS==0)
{
alert("还有最后五分钟!");
}
if(nH==0&nM==0&nS==0){
var paperForm=document.getElementById("ListForm");
paperForm.submit();
alert("考试时间到,试卷自动提交!");
}
setTimeout("GetRTime()",1000);
}
</script>
这个div的内容是用innerHTML方法写进去的,所以上段以移动就找不到内容了,
<style>
.div{
position: absolute;
border: 2px solid red;
background-color: #EFEFEF;
line-height:90px;
font-size:12px;
z-index:1000;
}
</style> <div id="Javascript.Div4" class="div" style="width: 240px; height:90px" align="center">time</div>
<SCRIPT LANGUAGE="JavaScript">
function sc4(){
document.getElementById("Javascript.Div4").style.top=(document.documentElement.scrollTop)+"px";
document.getElementById("Javascript.Div4").style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth-document.getElementById("Javascript.Div4").offsetWidth)+"px";
}
function callall(){
sc4();
}
window.onscroll=sc4;
window.onresize=sc4;
window.onload=callall;
//
</SCRIPT>
这样拷贝过去也不行.