js代码5秒后返回上一页面?

loveflydhl 2009-08-28 04:13:07
不会JS帮我写个 A页面跳到B页面,等待5秒后返回A页面


谢谢了。。。。。。。顺便学习。。。
...全文
655 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
wjyyeah 2009-08-28
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 wjyyeah 的回复:]
后台或者页面上这样写
Java code//最后一次网址String wz= request.getRequestURI();
String cs= request.getQueryString();if(cs==null)
{
session.setAttribute("zhwz",wz);
}else
{
session.setAttribute("zhwz",wz+"?"+cs);
}

JS部分
JScript codefunction tiaoZhuan()
{
window.location.href="<%=request.getAttribute("zhwz") %>";
}//2秒后执行window.setTimeout("tiaoZhuan()",2000 );
[/Quote]

String cs是参数
wjyyeah 2009-08-28
  • 打赏
  • 举报
回复
后台或者页面上这样写

//最后一次网址
String wz = request.getRequestURI();
String cs = request.getQueryString();
if(cs==null)
{
session.setAttribute("zhwz",wz);
}
else
{
session.setAttribute("zhwz",wz+"?"+cs);
}


JS部分

function tiaoZhuan()
{
window.location.href="<%=request.getAttribute("zhwz") %>";
}
//2秒后执行
window.setTimeout( "tiaoZhuan()",2000 );
BeenZ 2009-08-28
  • 打赏
  • 举报
回复
a.htm

<html>
<head>
<title></title>

<script>


</script>
</head>
<body >
<div><a href="b.htm">点这里进去B</a></div>
</body>
</html>


b.htm


<html>
<head>
<title></title>

<script>
var t
function returntoa(){
t=setTimeout(back,5000)
}
function back(){
parent.history.back();
}
</script>
</head>
<body onload="returntoa()">
<input type="text" name="textfield" id="textfield"/>
<input type="submit" name="Submit" value="提交" />
</body>
</html>
mykelly6 2009-08-28
  • 打赏
  • 举报
回复

<script type="text/javascript">
setTimeout("jump()",5000);

function jump(){
window.location.href="http://www.g.cn";
}
</script>

page B<BR>
jump after 5s...
popule_daisy 2009-08-28
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 hookee 的回复:]
A.htm
HTML code<ahref="B.htm">xxx</a>

B.htm
HTML code<script>
window.onload=function(){
setTimeout("history.back()",5000);
}</script>
[/Quote]

正确
hookee 2009-08-28
  • 打赏
  • 举报
回复
A.htm
<a href="B.htm">xxx</a>


B.htm

<script>
window.onload = function(){
setTimeout("history.back()", 5000);
}
</script>
BeenZ 2009-08-28
  • 打赏
  • 举报
回复

setTimeout(back(),5000)
function back(){
parent.history.back()
}

87,921

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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