ASP timed to perform operations ASP read the database (Web page timing operation) _ Thieves/Collection

Source: Internet
Author: User
Tags setinterval time interval
The current scheduled operations are:
One, the time refresh of the HTML page (refresh--refresh)
1,refresh (refresh) Code usage instructions
Description: Let the page refresh itself for how long (in seconds), or how long to have the page automatically link to other pages.
Usage: <meta http-equiv= "Refresh" content= ">"
<meta http-equiv= "Refresh" content= "5; Url=http://www.jb51.net ">
Note: 5 of which is to stop after 5 seconds to automatically refresh to URL URLs
2, how to operate the timer
You can refresh on the same page repeatedly to achieve the effect of timed operation.
such as: <meta http-equiv= "Refresh" content= "5; Url=http://www.jb51.net ">
Disadvantage: To open the page in the browser, you cannot close it.
second, settimeout and setinterval in JavaScript
The difference between 1,settimeout and setinterval
The Window object has two main timing methods, settimeout and Setinteval, whose syntax is essentially the same, but the completed functionality differs.
The SetTimeout method is the timer program, which is what to do after the time. Just finish it.
The SetInterval method is to indicate that an operation is repeated at a certain time interval.
If you implement the function of Setinerval with settimeout, you need to call yourself in the program you are executing. If you want to clear the counter you need to invoke different cleanup methods depending on the method you are using:
For example: Tttt=settimeout (' Hello () ', 1000);
Cleartimeout (TTTT);
Or:
Tttt=setinterval (' Hello () ', 1000);
Clearinteval (TTTT);
2, how to operate the timer
For example, to open the page regularly test.asp (of course test.asp can be read the database, generate static pages ...)
Copy Code code as follows:

<script language= "JavaScript" type= "Text/javascript" >
<!--
function Hello () {
window.open (' Http://www.jb51.net ')
}
Window.settimeout (Hello (), 5000);
-->
</script>

Disadvantage: To open the page in the browser, you cannot close it.
Third, the ASP uses VB to write the timing component
There is no settimeout this kind of timing statement in ASP, we need to use ASP component to solve, similarly, can use VB6 to compile, concrete operation method Reference
In order to suspend the thread, we need to use the WIN32API function sleep, the same new active DLL project, named Timer,
Class name is sleep.
Sleep This win32api function can be found in VB6 's own API text browser with its declarative method
Now the class Sleep program is as follows, this component program is very simple, I do not explain more.
Copy Code code as follows:

Private Declare Sub sleep Lib "kernel32" (ByVal dwmilliseconds as Long)
Private M_set as Long
Public Property Get Setup () as Long
Setup = M_set
End Property
Public Property Let Setup (Strset as Long)
M_set = Strset
End Property
Public Function Sleeptime ()
Sleep (Setup)
End Function

Compile it to generate Timer.dll This component DLL, if you do not write VB program, then you can also find in the downloaded package Timer.dll
This file. Copy it to the Windows directory and enter it in MS-DOS mode
C:\windows\regsvr32 Timer.dll
Complete the component registration, you can also use this timing component.
Now explain the ASP call file just by the first. See how this component uses
* Application of Timer
Copy Code code as follows:

<title> Timer application (from:http://www.jb51.net) </title>
<body>
<%
' This is the script execution time, default is 90 seconds, need to change a bit, otherwise in 90 seconds the program will be interrupted ' 3600 is an hour
server.scripttimeout=3600
Set Obj=server.createobject ("Timer.sleep")
' Parameter 1000 hangs for the thread for a second and can be set randomly
obj.setup=1000
Do While True
  
Obj.sleeptime
' Performs a timed operation,
If not response.isclientconnected Then
Set obj=nothing
Session.Abandon
End If
Loop
%>
</body>

Advantages: Here is just a random use of VB to write a test DLL, but with VB can certainly write a DLL inside a timed operation.
Disadvantage: Feel VB write this DLL may be the advantages of resources.
four, in conjunction with the computer's task scheduled operation, I personally think it is the best method at present.
This personal feeling is the best way to implement timed operation at present.
Is the first on the server to write a regular operation of the page, such as Test.asp
Then write a VBS file, as follows:
Copy Code code as follows:

Dim IE
Set IE = CreateObject ("Internetexplorer.application")
' Run your URL
Ie.navigate ("Http://www.jb51.net")
Ie.visible=1
' Clean up ...
Set IE = Nothing

1, you can use the Task Scheduler on the server
2, you can also use the Task Scheduler on the client computer
For specific use of the Task Scheduler, refer to the http://www.pclala.com/Pc/Skill/200851912807.Html
Pros and Cons: The page will be timed pop-up page test.asp, but there will be a solution, that is, in the Test.asp page to add a timed shutdown code:
Copy Code code as follows:

<script language= "JavaScript" >
<!--
SetTimeout (' Window.close (); ', 500);
-->
</script>

Summary, due to the current part of the Web language restrictions on the timing of the operation has a certain degree of difficulty, but after my many times to verify that the fourth method is undoubtedly the best effect, the most worry.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.