Javascript 关于动态倒计时重定向的错误

Javascript 关于动态倒计时重定向的错误,javascript,jquery,Javascript,Jquery,我有一个javascript在倒计时10秒后重定向到另一个页面,但它不起作用。有人能帮忙解决这个问题吗 <body> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script type ="text/javascript" src ="jquery.js"></script> &l

我有一个javascript在倒计时10秒后重定向到另一个页面,但它不起作用。有人能帮忙解决这个问题吗

<body>
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

        <script type ="text/javascript" src ="jquery.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {
            var number = 10;
            var url = 'http://localhost/rms/index.php/';

            function countdown() {
                setTimeout(countdown,1000);
                $('#title1').html("Redirecting in " + number + " seconds");
                number --;

                if(number<0) {
                    window.location = url;
                    number = 0;
                }
            }
            countdown();
        });
    </script>

    </head>
    <body>
   <div id="title1"></div>
    </body>

$(文档).ready(函数(){
var数=10;
var url='1〕http://localhost/rms/index.php/';
函数倒计时(){
设置超时(倒计时,1000);
$('#title1').html(“在“+number+”秒内重定向”);
数字--;

如果(数字和每个人在评论中写的一样,它应该有效。试着替换

<script type ="text/javascript" src ="jquery.js"></script>

为此:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script>

在这种情况下,您不必担心jquery.js文件可能丢失或损坏

我对你的代码有一个注释。你知道你调用window.location=url;两次了吗?
如果它只是一个带有重定向的规则倒计时,我会把StIdTimeOutin调用if语句,它将阻止调用它两次。

工作得很好:您的代码示例不会孤立这个问题,相反,它是有效的。请考虑创建一个代码示例来说明您的问题。jQuery是否存在于目录中…检查你的浏览器控制台应该可以工作。你可能在jquery路径上有问题。检查控制台是否有错误。同时检查你是否安装了阻止JavaScript重定向的插件(例如Firefox的Noscript)。