在打开一个新的页面后,想要原来的页面自动关闭的问题。

adaailpll 2006-05-24 05:20:55
我这段代码可以实现关闭,但是会弹出提示窗口,问你当前窗口要关闭,让你选择。但我想要的效果是自动关闭,不要弹出提示框架,请问怎么做?
代码如下:



<html>
<head>
<%
if session("spass")="" and session("sname")="" then
response.Write("您还没有登录或者网页已经过期,请回到<a href='../index.asp' >登录</a>页面!")
else
%>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="css/Style.css" rel="stylesheet" type="text/css">
<script language="javascript">
function closeit()
{
setTimeout("self.close()",6000);
window.openner=null;
}
</script>
<script language="javascript">
function close1(url)
{
var newwin=window.open(url,"winname","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=800,height=600");
newwin.focus();
return(newwin);

}
</script>
<style type="text/css">
<!--
.style1 {
color: #FF0000;
font-weight: bold;
}
.style2 {
color: #0000FF;
font-weight: bold;
}
.style3 {color: #0000FF}
.style6 {
color: #003300;
font-weight: bold;
}
.style7 {
color: #333300;
font-weight: bold;
}
.style8 {color: #003300}
-->
</style>
</head>

<body OnLoad="closeit()">



<p align="center" class="style1"> </p>
<p align="center" class="style1"><a href="11.asp">返回主页面</a></p>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>

<td width="49" height="35" background="../image/HOME_BG3.GIF"> </td>
<td height="35" background="../image/HOME_BG9.GIF"> <div align="center"><span class="Xsmall"><font color="#FF0000"><strong>欢迎光临基于web的在线考试系统</strong></font></span></div></td>
<td width="13" height="1"><img src="../image/home_bg8.gif" width="13" height="12"></td>
</tr>
<tr>
<td width="49" background="../image/HOME_BG1.GIF"> <br> </td>
<td background="../image/home_bg10.gif"> <p><span class="Xsmall">
<%
response.write(" "& session("name")&"同学:")
%>
<br>
   请验证一下你的学号是否正确!<img src="../image/forword_1.gif" width="16" height="15">
<%response.write("<font color=red>"&session("sname")&"</font>")%>
<br>
 若正确请点击开始进入在线考试,若错误请于考场老师联系!<br>
<br>
    <img src="../image/announce.gif" width="18" height="18">
在正式考试前,请阅读本考场规则,如下:</span></p>
<blockquote>
<p> <img src="../image/forget_1.gif" width="14" height="14"> <span class="Xsmall"><font color="#FF0000">答完题后记得</font><span class="style6">一定要保存答案</span><font color="#FF0000">,</font><span class="style3">否则成绩为0,<span class="style8">同时注意一但保存试卷后就不能再继续答题!</span></span></span><font color="#FF0000">保存完后记得要</font><span class="style7">提交试卷</span><font color="#FF0000">,</font><span class="style3">否则成绩同样为0!</span><br>
<img src="../image/forget_1.gif" width="14" height="14"> <span class="Xsmall"><font color="#FF0000">请不要点击刷新、后退等违纪按钮</font></span><br>
<img src="../image/forget_1.gif" width="14" height="14"> <span class="Xsmall"><font color="#FF0000">准时交卷,不拖交,时间到了系统会强制交卷!不允许继续答题!<br>
<img src="../image/forget_1.gif" width="14" height="14"> 不要违反考试各项规则<br>
<img src="../image/forget_1.gif" width="14" height="14"> 若违反,一律以零分处置</font></span></p>
</blockquote></td>
<td width="13" background="../image/home_bg7.gif"> </td>
</tr>
<tr>
<td width="49" height="42" background="../image/HOME_BG2.GIF"> </td>
<td height="22" background="../image/home_bg10.gif" bgcolor="#FFFFFF"><div align="center" class="style2"><a href="#" onClick="JavaScript:close1('gonewtest.asp')">开始考试
</a> </div></td>
<td width="13" height="22" background="../image/HOME_BG7.GIF"> </td>
</tr>
<tr>
<td height="12" background="../image/HOME_BG4.GIF"> </td>
<td background="../image/HOME_BG5.gif"> </td>
<td background="../image/HOME_BG6.GIF"> </td>
</tr>
</table>
<%end if%>
</body>
</html>


代码中的两个javascript 脚本一个是实现关闭,一个是实现打开一个没有工具栏等属性的新窗口。主要是关闭的那个实现不了我要的效果。
...全文
324 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
icefire988 2006-05-25
  • 打赏
  • 举报
回复
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript" type="text/javascript">
<!--//
function openwin()
{
var newwin=window.open("main.html","winname","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=800,height=600");
if (newwin != null) {
if (newwin.opener == null) {
newwin.opener = self;
}
}
newwin.focus();
window.opener = "xxx";
window.close();
}
//-->
</script>
</head>

<body>
<a href="#" onclick="openwin();">打开新窗口,并且关闭自己
</a>
</body>
</html>
adaailpll 2006-05-25
  • 打赏
  • 举报
回复
window.opener = "xxx ";

请问icefire988(冰火) 这句起到什么作用?
samjuly 2006-05-24
  • 打赏
  • 举报
回复
获取题目的同时记录session("timeout")=dateadd("s",30,now)考试剩余的时间=DateDiff("s",now(),session("timeout"),因为session("timeout")不变,所以就算刷新了,计时也不会重新开始
adaailpll 2006-05-24
  • 打赏
  • 举报
回复
当中的代码是可以实现关闭,但有提示框,这样来,人家肯定选择否的嘛。这样就没起到作用了,郁闷
chinastorm 2006-05-24
  • 打赏
  • 举报
回复
不太好实现,记号!
adaailpll 2006-05-24
  • 打赏
  • 举报
回复
题都不怕刷新。因为有一个时间控制问题。如果刷新了时间会从新计算,不好控制。

只要可以实现我要的效果,就OK了。
samjuly 2006-05-24
  • 打赏
  • 举报
回复
强制不能使用后退和刷新的话,可能有学生会误操作,不妨在网页功能上实现即使后退或者刷新了,同样不影响考试。为了防止刷新,估计你的题目是随即得到的,你可以把题目记录在session里面这样就不怕刷新,至于后退。。。还要想想
adaailpll 2006-05-24
  • 打赏
  • 举报
回复
samjuly() 您好!这是为了防止后退和刷新。
samjuly 2006-05-24
  • 打赏
  • 举报
回复
不妨考虑一下是否有必要用弹出窗口的模式,无非是多了toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=800,height=600这些属性,为了美观?
adaailpll 2006-05-24
  • 打赏
  • 举报
回复
上面的代码也能实现关闭,不过会弹出提示框。我想要的是自动关闭。不要弹出提示框。
adaailpll 2006-05-24
  • 打赏
  • 举报
回复
gxh7506(潇湘水云) 您好!
关闭父窗口:parent.window.close(); 这句应该加在那个地方?
gxh7506 2006-05-24
  • 打赏
  • 举报
回复
关闭父窗口:parent.window.close();
adaailpll 2006-05-24
  • 打赏
  • 举报
回复
up
adaailpll 2006-05-24
  • 打赏
  • 举报
回复
关闭是在这。<body OnLoad="closeit()">
adaailpll 2006-05-24
  • 打赏
  • 举报
回复
打开新窗口是段代码:
<td height="22" background="../image/home_bg10.gif" bgcolor="#FFFFFF"><div align="center" class="style2"><a href="#" onClick="JavaScript:close1('gonewtest.asp')">开始考试
</a> </div></td>

就是点击:开始考试。就打开新窗口

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧