|
 |
asp_web_howto thread: Delay Function
Message #1 by "Mark Collins" <mark.collins@c...> on Mon, 26 Feb 2001 14:35:21
|
|
Hi all,
I posted a query about a delay function, and have found out that there is
not such a thing.
The whole problem of ASP and HTML is made apparent at this point as I have
tried since to use a simple function as below:
####################################
HTML stuff here
more stuff
more stuff
<%
'all asp stuff here
delay = second(now)
delay = delay + 5
while second(now) <> delay
'do nothing
wend
%>
HTML stuff here
more stuff
more stuff
Enf of function
##############################
The problem with this is that the ASP is processed first then all the lot
is sent down as one lump of HTML, so we get as output:
HTML stuff here
more stuff
more stuff
HTML stuff here
more stuff
more stuff
there is of course a delay of 5 seconds before this where nothing happens.
Is there any way that I can implement 'Some HTML', then 'Some ASP',
then 'Some HTML'. Or something roundabouts?
The answer is probably no but I would really like to create a delay
function and have no idea how?
Any comments?
Regards
Mark.
Message #2 by "TomMallard" <mallard@s...> on Mon, 26 Feb 2001 07:26:21 -0800
|
|
If the second is 59 and you add 5 you get 64, a value which seconds can
never reach again. Therefore, you need to add a limit of 60 and re-compute
if the total exceeds it.
tom mallard
seattle
----- Original Message -----
From: "Mark Collins" <mark.collins@c...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Monday, February 26, 2001 2:35 PM
Subject: [asp_web_howto] Delay Function
> Hi all,
>
> I posted a query about a delay function, and have found out that there is
> not such a thing.
>
> The whole problem of ASP and HTML is made apparent at this point as I have
> tried since to use a simple function as below:
>
> ####################################
> HTML stuff here
> more stuff
> more stuff
>
> <%
> 'all asp stuff here
> delay = second(now)
> delay = delay + 5
>
> while second(now) <> delay
> 'do nothing
> wend
>
> %>
>
> HTML stuff here
> more stuff
> more stuff
>
> Enf of function
> ##############################
>
> The problem with this is that the ASP is processed first then all the lot
> is sent down as one lump of HTML, so we get as output:
>
> HTML stuff here
> more stuff
> more stuff
> HTML stuff here
> more stuff
> more stuff
>
> there is of course a delay of 5 seconds before this where nothing happens.
>
> Is there any way that I can implement 'Some HTML', then 'Some ASP',
> then 'Some HTML'. Or something roundabouts?
>
> The answer is probably no but I would really like to create a delay
> function and have no idea how?
>
> Any comments?
>
> Regards
>
> Mark.
>
Message #3 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Mon, 26 Feb 2001 15:46:59 -0000
|
|
you can create a delay in a client-side by using the setTimeout method
of
the browser
from MSDN:
setTimeout Method
------------------------------------------------------------------------
----
----
Evaluates an expression after a specified number of milliseconds has
elapsed.
Syntax
iTimerID =3D window.setTimeout(vCode, iMilliSeconds, sLanguage)
Parameters
vCode Required. Variant that specifies the function pointer or string
that
indicates the code to be executed when the specified interval has
elapsed.
iMilliSeconds Required. Integer that specifies the number of
milliseconds.
sLanguage Required. String that specifies one of the following values:
JScript Language is JScript.
VBScript Language is VBScript.
JavaScript Language is JavaScript.
Return Value
Integer. Returns an identifier that cancels the evaluation with the
clearTimeout method.
Remarks
In versions earlier than Microsoft=AE Internet Explorer 5, the first
argument
of setTimeout must be a string. Evaluation of the string is deferred
until
the specified interval elapses.
As of Internet Explorer 5, the first argument of setTimeout can be a
string
or a function pointer.
The specified expression or function is evaluated once. For repeated
evaluation, use the setInterval or setInterval method.
Example
The following example uses the setTimeout method to evaluate a simple
expression after one second has elapsed.
window.setTimeout("alert('Hello, world')", 1000);
The following example uses the setTimeout method to evaluate a slightly
more
complex expression after one second has elapsed.
var sMsg =3D "Hello, world";
window.setTimeout("alert(" + sMsg + ")", 1000);
This example uses the setTimeout method to hide a INPUT type=3Dbutton
object
after three seconds. If the user clicks the Count Down button and then
counts to three, the Now You See Me button disappears.
<SCRIPT>
function fnHide(oToHide){
window.setTimeout("fnHide2(" + oToHide.id + ")", 3000);
}
function fnHide2(sID){
var o =3D eval(sID);
o.style.display=3D"none";
}
</SCRIPT>
<INPUT TYPE=3Dbutton VALUE=3D"Now you see me ..."
ID=3D"oHideButton" onclick=3D"fnHide(this)">
This example uses a function pointer to pass the data. In this case,
the
data is stored in a global variable because it cannot be passed
directly. In
the preceding example, the ID of the button is passed as a parameter to
the
function invoked by the setTimeout method. This is possible only when a
string is passed as the first argument.
<SCRIPT>
var g_oToHide =3D null;
function fnHide(oToHide){
g_oToHide =3D oToHide;
window.setTimeout(fnHide2, 3000);
}
function fnHide2(sID){
if (g_oToHide) {
g_oToHide.style.display=3D"none";
}
}
</SCRIPT>
<INPUT TYPE=3Dbutton VALUE=3D"Now you see me ..." ID=3D"oHideButton"
onclick=3D"fnHide(this)">
-----Original Message-----
From: Mark Collins [mailto:mark.collins@c...]
Sent: Monday, February 26, 2001 2:35 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Delay Function
Hi all,
I posted a query about a delay function, and have found out that there
is
not such a thing.
The whole problem of ASP and HTML is made apparent at this point as I
have
tried since to use a simple function as below:
####################################
HTML stuff here
more stuff
more stuff
<%
'all asp stuff here
delay =3D second(now)
delay =3D delay + 5
while second(now) <> delay
'do nothing
wend
%>
HTML stuff here
more stuff
more stuff
Enf of function
##############################
The problem with this is that the ASP is processed first then all the
lot
is sent down as one lump of HTML, so we get as output:
HTML stuff here
more stuff
more stuff
HTML stuff here
more stuff
more stuff
there is of course a delay of 5 seconds before this where nothing
happens.
Is there any way that I can implement 'Some HTML', then 'Some ASP',
then 'Some HTML'. Or something roundabouts?
The answer is probably no but I would really like to create a delay
function and have no idea how?
Any comments?
Regards
Mark.
________________________________________________________________________
Scottish Enterprise Network
http://www.scottish-enterprise.com
Message #4 by "Mark Collins" <mark.collins@c...> on Tue, 27 Feb 2001 15:36:35
|
|
Thanks for the response Tom,
The mistake, on my part that you pointed out, I had already realised, but
I was just intending to show this code for the purpose of the subject in
hand. I Know to use some numeric functions for when time in seconds
exceeds 59, but the code was created within minutes just as a trial, and
with a few refreshes, it will work.
Thanks again
Regards
Mark.
|
|
 |