Help with Javascript

G

Guest

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(minutesToWait)%>')">
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(minutesToWait)%>')">



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
 
K

Kevin Spencer

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 said:
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)%>' said:
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
 
B

bruce barker

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)




| 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
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top