471,592 Members | 1,079 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,592 software developers and data experts.

Help with Javascript

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

Nov 19 '05 #1
2 1379
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" <Ch***@discussions.microsoft.com> wrote in message
news:4E**********************************@microsof t.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

Nov 19 '05 #2
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" <Ch***@discussions.microsoft.com> wrote in message
news:4E**********************************@microsof t.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
|
Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by TrvlOrm | last post: by
7 posts views Thread by mike | last post: by
9 posts views Thread by YZK | last post: by
5 posts views Thread by Craig Keightley | last post: by
reply views Thread by Erland | last post: by
1 post views Thread by JumpingOffPlace | last post: by
36 posts views Thread by aljamala | last post: by
7 posts views Thread by gubbachchi | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.