Due to the current language limitations of some web pages, there are certain difficulties in timing operations. However, after many verifications, I found that the fourth method is undoubtedly the most effective and the most worry-free. Current scheduled operations include:
1. Regular refresh of Html page (Refresh--refresh)
1. Refresh code usage instructions
Description: How long (seconds) does it take for the web page to refresh itself, or how long does it take for the web page to automatically link to other web pages.
Usage: <Meta http-equiv=Refresh Content=30>
<Meta http-equiv=Refresh Content=5; Url=http://www.vevb.com>
Note: The 5 means that it will automatically refresh to the URL after staying for 5 seconds.
2. How to operate regularly
You can refresh the same page repeatedly to achieve the effect of scheduled operations.
For example: <meta http-equiv=refresh content=5;URL=http://www.vevb.com>
Disadvantages: The page needs to be opened in the browser and cannot be closed.
2. setTimeout and setInterval in Javascript
1. The difference between setTimeout and setInterval
The window object has two main timing methods, namely setTimeout and setInteval. Their syntax is basically the same, but the completed functions are different.
The setTimeout method is a timing program, that is, what to do after a certain time. Pull it down when you're done.
The setInterval method means to repeatedly perform an operation at a certain interval.
If you use setTimeout to implement the function of setInerval, you need to call yourself regularly in the executing program. If you want to clear the counter, you need to call different clearing methods depending on 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 want to open the page Test.asp regularly (of course Test.asp can read the database and generate static pages...)
Copy the code code as follows:
<script language=JavaScript type=text/javascript>
<!--
function hello(){
window.open('Http://www.vevb.com')
}
window.setTimeout(hello(),5000);
//-->
</script>
Disadvantages: The page needs to be opened in the browser and cannot be closed.
3. ASP uses timing components written in VB
There are no timing statements such as setTimeout in ASP. We need to use ASP components to solve it. Similarly, we can use VB6 to compile it. For specific operation methods, please refer to
As in the previous component, in order to suspend the thread, we need to use the WIN32API function Sleep, and also create a new Active Dll project and name it Timer.
The class name is sleep.
The WIN32API function sleep can be found in its declaration method using the API text browser that comes with VB6.
The current sleep-like program is as follows. This component program is very simple, so I won’t explain it further.
Copy the 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 the component dll timer.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 to the windows directory and enter it in MS-DOS mode
c:/windows/regsvr32 timer.dll
After completing the component registration, you can also use this timing component.
Now explain the ASP call file just listed in detail. See how to use this component
*Application of timer
Copy the code code as follows:
<html>
<title>Timer application (From:Http://www.vevb.com)</title>
<head>
</head>
<body>
<%
'This is the script execution time, the default is 90 seconds, it needs to be 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 means the thread hangs for one second, which can be set at will.
obj.setup=1000
do while true
obj.sleeptime
'Perform scheduled operations,
If Not Response.IsClientConnected Then
set obj=nothing
session.abandon
End If
loop
%>
</body>
</html>
Advantages: I just used VB to write a test dll here, but I can definitely write a scheduled operation in the dll using VB.
Disadvantages: I feel that this dll written in VB may occupy resources.
Fourth, combined with the scheduled operation of the computer's task plan, I personally think it is the best method at present.
This personal feeling is currently the best way to implement timing operations.
That is to first write the page to be operated regularly on the server, such as Test.asp
Then write a vbs file as follows:
Copy the code code as follows:
DI
Set IE = CreateObject(InternetExplorer.Application)
'Run your URL
ie.navigate(http://www.vevb.com)
ie.visible=1
'Clean up...
Set IE=Nothing
1. You can use task scheduling on the server
2. You can also use the task schedule on the client computer
For specific usage of task plan, please refer to http://www.pclala.com/Pc/Skill/200851912807.Html
Advantages and Disadvantages: The page will pop up the Test.asp page regularly, but there is a solution, which is to add the scheduled closing code to the Test.asp page:
Copy the code code as follows:
<script LANGUAGE=JavaScript>
<!--
setTimeout('window.close();', 500);
// -->
</script>
In summary, due to the language limitations of some current web pages, there are certain difficulties in timing operations. However, after many verifications, I found that the fourth method is undoubtedly the best and most worry-free.