404错误,如何实现自动跳转 当用户访问不存在网页时,会自动跳转到404错误页面我现在想这样设置错误页面首先提示当前所获取的页面地址,并提示该地址不存在然后获取当前域名,经过10秒后自动跳转到当前域名的首页。JS源代码应该如何编写。谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!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>CSDN | 错误</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <style type="text/css"> html,body{margin:0;text-align:center;background:#fff;} body{font-size: 12px;} #wrap{width:500px;margin:auto; text-align:left; padding:20px;padding-top:50px;} #logo{position: relative; width:90px;padding: 65px 0 65px 0;} #content{position: absolute;padding: 20px;margin-left: 110px; margin-top:-180px; height: 140px;border-left: solid 1px #999;} h2{font-size: 16px;} a:link,a:visited,a:hover,a:active{text-decoration:none;color: #900;} a:hover{text-decoration:underline;} li{line-height:22px;} </style></head><body> <div id="wrap"> <script type="text/javascript"> var sec=10; </script> <div id="logo"> <img src="http://c.csdn.net/bbs/t/5/i/pic_logo.gif" style="border: 0;" width="90" height="50" alt="CSDN Logo" /></div> <div id="content"> <h2> 噢!在你访问时发生了错误 !</h2> <p> 可能是你要访问的页面不存在,请确认再重试。 </p> <p> 你还可以…</p> <ul> <li><a href="http://www.csdn.net/" onclick="history.back();return false;">返回上一页</a></li> <li><a id="second" href="http://www.csdn.net/"> <script type="text/javascript">document.write(sec)</script> 秒钟后将返回首页</a></li> </ul> </div> </div> <script type="text/javascript"> function jump() { location.href="/"; } var s=0; function show() { s=s+1; if (s>sec) return; o=document.getElementById('second'); o.innerHTML=(sec-s)+'秒钟后将会跳转到首页'; } setTimeout('jump()',sec*1000); setInterval('show()',1000); </script></body></html> 404页面需要在服务器上设置调用你的404页面apache的可以用.htaccess处理 .htaccess处理这个如何处理?具体语法如何? 跟客户端没关系,你的服务器是iis还是别的? JS是验证客户端,404是服务器端的啊!~要用jsp来验证 先在web.xml里配个404的错误页面。在错误页面里运行js延迟10秒自动跳转就ok了 参照这篇文章吧,你就会清楚了,301跳转与URL转发。 在web。config中配置 <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"> <error statusCode="404" redirect="FileNotFound.htm" /> </customErrors>redirect中写你要跳到的页面就行了! 其实404错误可以在web xml配置文件中配置的 404主要检查action里面的配置路劲吧 javascript在firefox下创建xml文件的问题 jquery关于border-bottom-width和eval的问题 js闭包与变量问题 求一个JS等待效果 谁能帮我解释一下这个是javascript的语法还是css的语法,具体是定义什么呀 为什么V8引擎这么快? JSP控件 button的问题 急!!!!!!在线等! 有关下拉列表框的问题,请帮忙! 为什么FF和IE的区别那么大,关于cursor js中求工作日
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSDN | 错误</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
html,body{margin:0;text-align:center;background:#fff;}
body{font-size: 12px;}
#wrap{width:500px;margin:auto; text-align:left; padding:20px;padding-top:50px;}
#logo{position: relative; width:90px;padding: 65px 0 65px 0;}
#content{position: absolute;padding: 20px;margin-left: 110px; margin-top:-180px; height: 140px;border-left: solid 1px #999;}
h2{font-size: 16px;}
a:link,a:visited,a:hover,a:active{text-decoration:none;color: #900;}
a:hover{text-decoration:underline;}
li{line-height:22px;}
</style>
</head>
<body>
<div id="wrap"> <script type="text/javascript"> var sec=10; </script> <div id="logo">
<img src="http://c.csdn.net/bbs/t/5/i/pic_logo.gif" style="border: 0;" width="90"
height="50" alt="CSDN Logo" /></div>
<div id="content">
<h2>
噢!在你访问时发生了错误 !</h2>
<p>
可能是你要访问的页面不存在,请确认再重试。
</p>
<p>
你还可以…</p>
<ul>
<li><a href="http://www.csdn.net/" onclick="history.back();return false;">返回上一页</a></li>
<li><a id="second" href="http://www.csdn.net/"> <script type="text/javascript">document.write(sec)</script> 秒钟后将返回首页</a></li>
</ul>
</div>
</div> <script type="text/javascript">
function jump()
{
location.href="/";
}
var s=0;
function show()
{
s=s+1;
if (s>sec) return;
o=document.getElementById('second');
o.innerHTML=(sec-s)+'秒钟后将会跳转到首页';
}
setTimeout('jump()',sec*1000);
setInterval('show()',1000);
</script></body>
</html>
apache的可以用.htaccess处理
要用jsp来验证
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>redirect中写你要跳到的页面就行了!