Recommended: Teach you how to use ASP to create website forums DIY(1) Preface: There are now forums everywhere on the Internet, but I wonder if you have encountered this situation: finding what you want in the messy discussion information is a time-consuming and laborious thing. Later, you don’t want to go to any forums. So can we be right
Asp timing operation, Asp timing reading database (detailed explanation of web page timing operation)
'-----------------------------------------------------------------------------------------------------------------------------
'-----------Author:Vbell----------------------------------
'-----------Date:13:57 2008-5-19-------------------------
'-----------Http:www.qqview.com---------------------------
'--------------------------------------------------------------
Currently scheduled operations include:
1. Refresh on the Html page regularly (Refresh)
1. Refresh (refresh) code usage instructions
Description: How long (seconds) to refresh yourself, or how long after the web page automatically links to other web pages.
Usage: <Meta http-equiv=Refresh Content=30>
<Meta http-equiv=Refresh Content=5; Url=http://www.qqview.com>
Note: 5 of them means that you will automatically refresh to the URL after staying for 5 seconds.
2. How to operate regularly
You can refresh repeatedly on the same page to achieve the effect of timing operations.
For example: <meta http-equiv=refresh content=5;URL=http://www.qqview.com/test.asp>
Disadvantages: You must open the page in the browser, and cannot close it.
2. SetTimeout and setInterval in Javascript
1. The difference between setTimeout and setInterval
There are two main timing methods for window objects, namely setTimeout and setInteval. Their syntax is basically the same, but the completed functions are different.
The setTimeout method is a timed program, that is, at what time to do. After finishing it, it will be over.
The setInterval method means that a certain operation is repeatedly executed during a certain interval.
If you use setTimeout to implement the function of setInterval, you need to call yourself regularly in the executed program. If you want to clear the counter, you need to call different clear methods according to the method used:
For example: tttt=setTimeout('hello()',1000);
clearTimeout(tttt);
or:
tttt=setInterval('hello()',1000);
clearInteval(tttt);
2. How to operate regularly
For example, you need to open the page Test.asp regularly (of course, Test.asp can be a reading database and generating static pages...)
<script language=JavaScript type=text/javascript>
<!--
function hello(){
window.open('Http://www.qqview.com/Test.asp')
}
window.setTimeout(hello(),5000);
//-->
</script>
Disadvantages: You must open the page in the browser, and cannot close it.
3. ASP uses VB writing timing components
There are no timing statements like setTimeout in ASP. We need to use ASP components to solve them. Similarly, VB6 can be used to compile them. For specific operation methods, please refer to
The previous component is used to hang threads. In order to suspend threads, we need to use the WIN32API function Sleep, and also create a new Active Dll project, named Timer.
The class name is sleep.
The WIN32 API function sleep can be found in the API text browser provided by VB6.
Now the sleep-like program is as follows. This component program is very simple, I won’t explain it much.
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 and generate the timer.dll component dll. If you don't know how to write VB programs, you can also find timer.dll in the downloaded file package
This file. Copy it into the Windows directory and enter it in MS-DOS mode
c:/windows/regsvr32 timer.dll
After completing component registration, you can also use this timing component.
Now explain the ASP call file that just clicked on a column. See how this component is used
* Application of timer
<html>
<title>Application of timer (From:Http://www.QQview.com)</title>
<head>
</head>
<body>
<%
'This is the script execution time, the default is 90 seconds, and it needs to be changed a little longer, otherwise the program will be interrupted after 90 seconds' 3600 is one hour
Server.ScriptTimeOut=3600
set obj=server.createobject(timer.sleep)
'Parameter 1000 is for thread hang for one second, and can be set at will
obj.setup=1000
do while true
obj.sleeptime
'Perform a timing operation,
If Not Response.IsClientConnected Then
set obj=nothing
session.abandon
End If
loop
%>
</body>
</html>
Advantages: Here I just write a test dll with VB, but using VB can definitely write a timed operation in the dll.
Disadvantages: I feel that this dll written by VB may have advantages and resources.
4. Combined with the timing operation of computer task planning, I personally think it is the best method at present.
This personal feeling is the best way to implement timing operations at present.
It is to write the page to operate regularly on the server, such as Test.asp
Then write a vbs file as follows:
Dim IE
Set IE = CreateObject(InternetExplorer.Application)
'Run your URL
ie.navigate(http://www.qqview.com/Test.asp)
ie.visible=1
'Clean up...
Set IE = Nothing
1. You can use task schedule on the server
2. You can also use task schedule on the client
For specific use of task plan, please refer to http://www.pclala.com/Pc/Skill/200851912807.Html
Advantages and Disadvantages: The page will pop up the page Test.asp regularly, but there will be a solution, which is to add a timed closing code to the Test.asp page:
<script LANGUAGE=JavaScript>
<!--
setTimeout('window.close();', 500);
// -->
</script>
In summary, due to the current limitations of some web page languages, there are certain difficulties in timing operation, but after many verifications, I found that the fourth method is undoubtedly the best and most worry-free.
This article is entrusted to the online base camp to publish. Please bring copyright information when reprinting. Thanks.
Share: ASP implements a code program that tests network speed with progress bars ASP realizes test network speed with progress bar. Save the following code as a .ASP file and place it on your server and run it directly. The following is the referenced content: <%Response.E