Connecting Tech Pros Worldwide Forums | Help | Site Map

Help with Javascript

Chris
Guest
 
Posts: n/a
#1: Nov 19 '05
Hi,
I have a Javascript function that loads a page with a progress bar for long
process. The progress bar is a gif animation and for some reason it the
animation is stuck when the function is called so it looks like an image and
not an animation. I have decided to put a wait function that will pause for 3
sec so that the animation will be loaded then the call the function for the
long process.

This is the <SCRIPT> section

<SCRIPT language="javascript">

<body MS_POSITIONING="GridLayout"
onload="pause('<%Response.Write(redirectPage)%>',' <%Response.Write(Request.Url.Query)%>','<%Response .Write(secondsToWait)%>','<%Response.Write(minutes ToWait)%>')">
var i = 0;

function redirectTo(targetPage, querystring, secondsForWaiting,
minutesForWaiting)
{
if (0 < targetPage.length)
{

location.replace(targetPage + querystring);

if (secondsForWaiting.valueOf() > 0)
{
msgLabel.innerText =
"This process can take up to "
+ secondsForWaiting + " seconds...";
timedIterations(secondsForWaiting);
}
else
{
if (minutesForWaiting.valueOf() > 0)
{
msgLabel.innerText =
"This process can take up to "
+ minutesForWaiting + " minutes...";
timedIterations(minutesForWaiting * 60);
}
}
}
else
{
msgLabel.innerText = "Page not found."
}
}

function timedIterations(secondsForIterating)
{
incrementalWidth = 800 / secondsForIterating;
if (i <= secondsForIterating + 10)
{


setTimeout(
"timedIterations(" + secondsForIterating + ");",
1000);
i++;
}
else
{

ProcessingLabel.innerText =
"The server is taking longer than "
+ "anticipated to process your request. "
+ "Thank you for your patience. "
+ "You can wait a few minutes longer for "
+ "the process to complete, or you can press "
+ "the back button and try again later...";
}
}



function pause(targetPage, querystring, secondsForWaiting,
minutesForWaiting)
{
setTimeout('redirectTo(targetPage, querystring, secondsForWaiting,
minutesForWaiting)',3*1000); <========== I am having the error here.
}




</SCRIPT>


this is the load event of my form

<body MS_POSITIONING="GridLayout"
onload="pause('<%Response.Write(redirectPage)%>',' <%Response.Write(Request.Url.Query)%>','<%Response .Write(secondsToWait)%>','<%Response.Write(minutes ToWait)%>')">



On the load event I call the pause() FUNCTION which then pause for 3 secs so
that the page with the animation is loaded then the pause() FUNCTION calls
the function the calls the page with the long process. The problem is when my
page loads and call the pause function I get the runtime error:


"A runtime error has occured

Line 74

Error: Unterminated string constant"

Any ideas?

Thanks


Kevin Spencer
Guest
 
Posts: n/a
#2: Nov 19 '05

re: Help with Javascript


You can enable JavaScript debugging on your local test machine. First, in
your browser, under Tools|Internet Options|Advanced tab, uncheck the
"Disable Script Debugging" option. Then, the browser will offer to open a
debugging window when a JavaScript error occurs, and you can debug your
JavaScript just like any other code you write. You can set break points by
typing "debugger:" in a line by itself anywhere youwant the script to break.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Chris" <Chris@discussions.microsoft.com> wrote in message
news:4E76C64D-D23E-4B8D-86D4-5A728EF006CF@microsoft.com...[color=blue]
> Hi,
> I have a Javascript function that loads a page with a progress bar for[/color]
long[color=blue]
> process. The progress bar is a gif animation and for some reason it the
> animation is stuck when the function is called so it looks like an image[/color]
and[color=blue]
> not an animation. I have decided to put a wait function that will pause[/color]
for 3[color=blue]
> sec so that the animation will be loaded then the call the function for[/color]
the[color=blue]
> long process.
>
> This is the <SCRIPT> section
>
> <SCRIPT language="javascript">
>
> <body MS_POSITIONING="GridLayout"
>[/color]
onload="pause('<%Response.Write(redirectPage)%>',' <%Response.Write(Request.U
rl.Query)%>','<%Response.Write(secondsToWait)%>',' <%Response.Write(minutesTo
Wait)%>')">[color=blue]
> var i = 0;
>
> function redirectTo(targetPage, querystring, secondsForWaiting,
> minutesForWaiting)
> {
> if (0 < targetPage.length)
> {
>
> location.replace(targetPage + querystring);
>
> if (secondsForWaiting.valueOf() > 0)
> {
> msgLabel.innerText =
> "This process can take up to "
> + secondsForWaiting + " seconds...";
> timedIterations(secondsForWaiting);
> }
> else
> {
> if (minutesForWaiting.valueOf() > 0)
> {
> msgLabel.innerText =
> "This process can take up to "
> + minutesForWaiting + " minutes...";
> timedIterations(minutesForWaiting * 60);
> }
> }
> }
> else
> {
> msgLabel.innerText = "Page not found."
> }
> }
>
> function timedIterations(secondsForIterating)
> {
> incrementalWidth = 800 / secondsForIterating;
> if (i <= secondsForIterating + 10)
> {
>
>
> setTimeout(
> "timedIterations(" + secondsForIterating + ");",
> 1000);
> i++;
> }
> else
> {
>
> ProcessingLabel.innerText =
> "The server is taking longer than "
> + "anticipated to process your request. "
> + "Thank you for your patience. "
> + "You can wait a few minutes longer for "
> + "the process to complete, or you can press "
> + "the back button and try again later...";
> }
> }
>
>
>
> function pause(targetPage, querystring, secondsForWaiting,
> minutesForWaiting)
> {
> setTimeout('redirectTo(targetPage, querystring, secondsForWaiting,
> minutesForWaiting)',3*1000); <========== I am having the error here.
> }
>
>
>
>
> </SCRIPT>
>
>
> this is the load event of my form
>
> <body MS_POSITIONING="GridLayout"
>[/color]
onload="pause('<%Response.Write(redirectPage)%>',' <%Response.Write(Request.U
rl.Query)%>','<%Response.Write(secondsToWait)%>',' <%Response.Write(minutesTo
Wait)%>')">[color=blue]
>
>
>
> On the load event I call the pause() FUNCTION which then pause for 3 secs[/color]
so[color=blue]
> that the page with the animation is loaded then the pause() FUNCTION calls
> the function the calls the page with the long process. The problem is when[/color]
my[color=blue]
> page loads and call the pause function I get the runtime error:
>
>
> "A runtime error has occured
>
> Line 74
>
> Error: Unterminated string constant"
>
> Any ideas?
>
> Thanks
>[/color]


bruce barker
Guest
 
Posts: n/a
#3: Nov 19 '05

re: Help with Javascript


i assume the <body> is not really in a script block. on the line:

setTimeout('redirectTo(targetPage, querystring, secondsForWaiting,
minutesForWaiting)',3*1000);

setTimeout wants a string to exec. any variables referenced must be global,
or they will not be defined. also this still will not be reliable, the gif
animation will probably stop when you execute the replace.

also try this syntax:

<body MS_POSITIONING="GridLayout"
onload="pause('<%=redirectPage%>',
'<%=Request.Url.Query%>',
'<%=secondsToWait)%>',
'<%=minutesToWait%>')">


-- bruce (sqlwork.com)




"Chris" <Chris@discussions.microsoft.com> wrote in message
news:4E76C64D-D23E-4B8D-86D4-5A728EF006CF@microsoft.com...
| Hi,
| I have a Javascript function that loads a page with a progress bar for
long
| process. The progress bar is a gif animation and for some reason it the
| animation is stuck when the function is called so it looks like an image
and
| not an animation. I have decided to put a wait function that will pause
for 3
| sec so that the animation will be loaded then the call the function for
the
| long process.
|
| This is the <SCRIPT> section
|
| <SCRIPT language="javascript">
|
| <body MS_POSITIONING="GridLayout"
|
onload="pause('<%Response.Write(redirectPage)%>',' <%Response.Write(Request.U
rl.Query)%>','<%Response.Write(secondsToWait)%>',' <%Response.Write(minutesTo
Wait)%>')">
| var i = 0;
|
| function redirectTo(targetPage, querystring, secondsForWaiting,
| minutesForWaiting)
| {
| if (0 < targetPage.length)
| {
|
| location.replace(targetPage + querystring);
|
| if (secondsForWaiting.valueOf() > 0)
| {
| msgLabel.innerText =
| "This process can take up to "
| + secondsForWaiting + " seconds...";
| timedIterations(secondsForWaiting);
| }
| else
| {
| if (minutesForWaiting.valueOf() > 0)
| {
| msgLabel.innerText =
| "This process can take up to "
| + minutesForWaiting + " minutes...";
| timedIterations(minutesForWaiting * 60);
| }
| }
| }
| else
| {
| msgLabel.innerText = "Page not found."
| }
| }
|
| function timedIterations(secondsForIterating)
| {
| incrementalWidth = 800 / secondsForIterating;
| if (i <= secondsForIterating + 10)
| {
|
|
| setTimeout(
| "timedIterations(" + secondsForIterating + ");",
| 1000);
| i++;
| }
| else
| {
|
| ProcessingLabel.innerText =
| "The server is taking longer than "
| + "anticipated to process your request. "
| + "Thank you for your patience. "
| + "You can wait a few minutes longer for "
| + "the process to complete, or you can press "
| + "the back button and try again later...";
| }
| }
|
|
|
| function pause(targetPage, querystring, secondsForWaiting,
| minutesForWaiting)
| {
| setTimeout('redirectTo(targetPage, querystring, secondsForWaiting,
| minutesForWaiting)',3*1000); <========== I am having the error here.
| }
|
|
|
|
| </SCRIPT>
|
|
| this is the load event of my form
|
| <body MS_POSITIONING="GridLayout"
|
onload="pause('<%Response.Write(redirectPage)%>',' <%Response.Write(Request.U
rl.Query)%>','<%Response.Write(secondsToWait)%>',' <%Response.Write(minutesTo
Wait)%>')">
|
|
|
| On the load event I call the pause() FUNCTION which then pause for 3 secs
so
| that the page with the animation is loaded then the pause() FUNCTION calls
| the function the calls the page with the long process. The problem is when
my
| page loads and call the pause function I get the runtime error:
|
|
| "A runtime error has occured
|
| Line 74
|
| Error: Unterminated string constant"
|
| Any ideas?
|
| Thanks
|


Closed Thread