0

参考这篇文章我有这种情况

<html>
 <head>
  <script>
    // Our countdown plugin takes a callback, a duration, and an optional message
    $.fn.countdown = function (callback, duration, message) {
    // If no message is provided, we use an empty string
    message = message || "";
    // Get reference to container, and set initial content
    var container = $(this[0]).html(duration + message);
    // Get reference to the interval doing the countdown
    var countdown = setInterval(function () {
        // If seconds remain
        if (--duration) {
            // Update our container's message
            container.html(duration + message);
        // Otherwise
        } else {
            // Clear the countdown interval
            clearInterval(countdown);
            // And fire the callback passing our container as `this`
            callback.call(container);   
        }
    // Run interval every 1000ms (1 second)
    }, 1000);

    };
    // Function to be called after 5 seconds
     function redirect () {
     this.html("<a href='mypdf.pdf'>Donwload</a>");
     window.location = "http://msdn.microsoft.com";
     }
  </script>
 
 </head>
  <body>

现在,在"<boby>"标记之后,我有一个经典的 Asp response.write/flush,如下所示:

<%
  ToLoop = 29
  for i = 0 to ToLoop
      StartTimer = Timer 'define time in second from 12:00AM

       if i = 1 then
         Count_Start_Second = round(This_Loop_Timer * ToLoop) 'use round for integer a decimal number
           response.write "<div id='countdown'></div>"
           response.write"<script>" & _
            "$('#countdown').countdown(redirect, " & Count_Start_Second & ", ""s remaining"");" & _
             "</script>"
           response.flush 
       end if

         --------More and more asp code to compile a dinamic PDF----------

        EndTimer = Timer 'define time in second after loop
        This_Loop_Timer = EndTimer - StartTimer 
  next
%>

我不明白为什么在页面加载完成后执行 jQuery?从理论上讲,Flush 应该在循环的第一圈后立即加载。但不是。

4

0 回答 0