404跳转页面5秒倒计时页面跳转

来源:互联网 发布:矩阵式大灯 编辑:程序博客网 时间:2024/05/16 04:58
<!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=utf-8" /><title>jquery和JavaScript404跳转页面5秒倒计时页面跳转</title><meta name="description" content="jQuery和JavaScript两个版本的404跳转页面效果,利用倒计时间控制页面在规定多少秒时间内,页面跳转到指定的页面跳转过程。" /><style type="text/css">html{background:url(images/paper.jpg)!important;}a,fieldset,img{border:0;}a{color:#221919;text-decoration:none;outline:none;}a:hover{color:#3366cc;text-decoration:underline;}body{font-size:24px;color:#B7AEB4;}body a.link,body h1,body p{-webkit-transition:opacity 0.5s ease-in-out;-moz-transition:opacity 0.5s ease-in-out;transition:opacity 0.5s ease-in-out;}#wrapper{text-align:center;margin:100px auto;width:594px;}a.link{text-shadow:0px 1px 2px white;font-weight:600;color:#3366cc;opacity:0;}h1{text-shadow:0px 1px 2px white;font-size:24px;opacity:0;}img{-webkit-transition:opacity 1s ease-in-out;-moz-transition:opacity 1s ease-in-out;transition:opacity 1s ease-in-out;height:202px;width:199px;opacity:0;}p{text-shadow:0px 1px 2px white;font-weight:normal;font-weight:200;opacity:0;}.fade{opacity:1;}@media only screen and (min-device-width:320px) and (max-device-width:480px){#wrapper{margin:40px auto;text-align:center;width:280px;}}</style><strong><script type="text/javascript" src="js/jquery-1.4.2.min.js"></script></strong><!--解决 IE6 背景缓存--><!--[if IE 6]><script type="text/javascript">document.execCommand("BackgroundImageCache", false, true);</script><![endif]--><script type="text/javascript">$(document).ready(function(){if (!$.browser.msie){$("img").addClass('fade').<strong>delay(800)</strong>.queue(function(next){$("h1, p").addClass("fade");$("a.link").css("opacity", 1);next();});}else{$("img, h1, p").addClass('fade');$('a.link').css('opacity', 1);}});</script></head><body>    <div id="wrapper">        <a href="http://www.baidu.com"><img src="images/404_icon.png"></a>        <div>            <h1>唉呀!</h1>            <p>你正在寻找的页面无法找到。<a style="color:#ff6600;" href="http://www.17sucai.com/">可能在这里!</a></p>            <a class="link" href="/" onclick="history.go(-1)"><span id="sec">5</span> 秒后返回首页</a><br /><br /><br />        </div>    </div><script type="text/javascript">$(function () {               setTimeout("lazyGo();", 1000);  //在一秒之后执行lozyG0()这函数});function lazyGo() {var sec = $("#sec").text();$("#sec").text(--sec);     //text()设置或返回被选元素的文本内容。if (sec > 0)setTimeout("lazyGo();", 1000);elsewindow.location.href = "http://www.baidu.com";}</script></body></html>
</pre><pre>

注意:测试效果的时候要链接  jquery-1.4.2.min.js
相关知识讲解:
 setTimeout("lazyGo();", 1000);  //在一秒之后执行lozyG0()这函数
 text()设置或返回被选元素的文本内容。
 delay() 方法对队列中的下一项的执行设置延迟。
queue() 方法显示或操作在匹配元素上执行的函数队列
<addClass() 方法向被选元素添加一个或多个类
css() 方法设置或返回被选元素的一个或多个样式属性。
next() 获得匹配元素集合中每个元素紧邻的同胞元素。如果提供选择器,则取回匹配该选择器的下一个同胞元素。
css3属性:opacity  :设置 div 元素的不透明级别 ,默认为1


0 0
原创粉丝点击