473,387 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Gif won't run while processing is taking place

Frinavale
9,735 Expert Mod 8TB
Hi there,

I'm developing a web application system and at times the processing takes a while to finish. In order to keep the users from closing the browser before my site is finished working, I thought I'd display an animated .gif that would indicate my system was doing something.

The problem I'm having is that the gif doesn't do its animated thing when my site is processing. A progress bar is displayed and shows some progress at the bottom of the browser but the gif won't do its thing.

Does anyone know how I can get around this problem?

Thanks in advance
-Frin
Jan 15 '07 #1

✓ answered by iam_clint

The Javascript I use
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function pwait(count, co, color) {
  3.  if (count == 1) { document.getElementById("pwimg").src = "images/pwait.gif"; }
  4.  //border-top: solid 2px black; border-bottom: solid 2px black; border-right: solid 2px black; border-left: solid 2px black;
  5.  var ftable = document.getElementById("pwtable");
  6.  if (co == 1) {
  7.   ftable.style.borderTop = "solid 2px "+color;
  8.   ftable.style.borderBottom = "solid 2px black";
  9.   ftable.style.borderLeft = "solid 2px black";
  10.   ftable.style.borderRight = "solid 2px black";
  11.  }
  12.  if (co == 2) {
  13.   ftable.style.borderTop = "solid 2px black";
  14.   ftable.style.borderBottom = "solid 2px black";
  15.   ftable.style.borderLeft = "solid 2px "+color;
  16.   ftable.style.borderRight = "solid 2px black";
  17.  }
  18.  if (co == 3) {
  19.   ftable.style.borderTop = "solid 2px black";
  20.   ftable.style.borderBottom = "solid 2px "+color;
  21.   ftable.style.borderLeft = "solid 2px black";
  22.   ftable.style.borderRight = "solid 2px black";
  23.  }
  24.  if (co == 4) { 
  25.   ftable.style.borderTop = "solid 2px black";
  26.   ftable.style.borderBottom = "solid 2px black";
  27.   ftable.style.borderLeft = "solid 2px black";
  28.   ftable.style.borderRight = "solid 2px "+color;
  29.   co = 0; 
  30.  }
  31.  document.getElementById("pleasewait").style.visibility = "visible";
  32.     document.getElementById("pleasewait").style.top = document.body.scrollTop+document.documentElement.scrollTop+200;
  33.     document.getElementById("pleasewait").style.left = document.body.scrollLeft+document.documentElement.scrollLeft+500;
  34.  tmp = document.getElementById("pwait").innerHTML;
  35.  if (tmp == "&nbsp;") {
  36.   document.getElementById("pwait").innerHTML = ".";
  37.  }
  38.  if (tmp == ".") {
  39.   document.getElementById("pwait").innerHTML = "..";
  40.  }
  41.  if (tmp == "..") {
  42.   document.getElementById("pwait").innerHTML = "...";
  43.  }
  44.  if (tmp == "...") {
  45.   document.getElementById("pwait").innerHTML = "&nbsp;";
  46.  }
  47.  co = co + 1;
  48.  count = count + 1;
  49.  var pwaitint = window.setTimeout("pwait("+count+", "+co+", '"+color+"')", 200);
  50. }  
  51. </script>
  52.  
The Div I Use.
Expand|Select|Wrap|Line Numbers
  1. <div id="pleasewait" style="position: absolute; top: 200; left: 400; width: 180; height: 60; visibility: hidden;"><table width="100%" height="100%" bgcolor="white" style="border-top: solid 2px black; border-bottom: solid 2px black; border-right: solid 2px black; border-left: solid 2px black;" id="pwtable"><tr><td><img src="/images/pwait.gif" id="pwimg"><td width="70%" align="right" style="font-weight: 800;">Please Wait<td id="pwait" width="30%" align="left" style="font-weight: 800;">&nbsp;</table></div>
  2.  
When I call it
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function addcart() {
  3. var parts = document.getElementsByName("nparts");
  4. var mfgs = document.getElementsByName("suplier");
  5. var options = document.getElementsByName("option");
  6. var qstring = ""
  7. for (i=0; i<=options.length-1; i++) {
  8. if (options[i].checked) {
  9. qstring = qstring+"&nparts="+parts[i].value+"&suplier="+mfgs[i].value+"&qty=1"
  10. }
  11. }
  12. if (qstring!="") {
  13. pwait(0, 1, 'black');
  14. document.getElementById("favadd").disabled = true;
  15. window.location = "cart_add.asp?val=1"+qstring
  16. } else {
  17. alert("You didn't mark anything to be added!");
  18. }
  19. }
  20. </script>
  21.  
Cart add redirects you to cart_view, cart_view takes awhile to load due to it using ajax to query a database located on someone elses server to check stock levels and things like that.

20 4350
b1randon
171 Expert 100+
Frin, I work on an application that does exactly this. You might want to think about using ajax. Ajax will allow you to check on the server's progress on your task intermittently. Also, since your page will no longer be loading it may clear up the problem with the animated gif (our project uses on too without issue).
Jan 15 '07 #2
Frinavale
9,735 Expert Mod 8TB
Frin, I work on an application that does exactly this. You might want to think about using ajax. Ajax will allow you to check on the server's progress on your task intermittently. Also, since your page will no longer be loading it may clear up the problem with the animated gif (our project uses on too without issue).

I have absolutely no experience with Ajax. I hadn't even heard of it 'til the other month when I started posting on this forum.

Is it easy to learn?
Is it easily incorporated into a .NET application?
Is it anything like JavaScript?

Thanks for the suggestion

-Frinny
Jan 15 '07 #3
AricC
1,892 Expert 1GB
Hey Frin, how much data are you processing? Is this in ASP? You could use Application.Lock while your processing ( performance may be an issue )

(Moved thread to Javascript/Ajax)
Jan 15 '07 #4
Frinavale
9,735 Expert Mod 8TB
Hey Frin, how much data are you processing? Is this in ASP? You could use Application.Lock while your processing ( performance may be an issue )

(Moved thread to Javascript/Ajax)

I'm using VB .Net (which uses asp of course)

I'm doing a bunch of validation requests that run against a database. Its quite a bit of processing and for the database to timeout its sometimes taking something like 30seconds...

I've never heard of Application.Lock before.
I'm going to look into it now to see if it could help me.

I just looked up Ajax stuff and even though it looks like something I'd want to implement in the future...I can't really learn this right now and write the server side functions since my project is going to be launched within the next couple of days.

I didn't think it would take much to get an animated .gif to run while sever processing was happening. I guess I was wrong.

Thanks for all your help
-Frinny
Jan 15 '07 #5
AricC
1,892 Expert 1GB
I don't think it is that difficult, in fact I'm moving this to the .Net forum and copy the ASP forum as this is more of an ASP.Net issue. As a work around for the time being maybe this solution would work. While the user is in the process if in your Try/Catch you hit an excError ( what I call mine ) throw the error to a log file on your server. Then just check the log file for errors daily or write a script to get it emailed to you. I have a great example of a VB.Net error file writer if you need one. I will just need to dig it up. Let me know.


HTH,
Aric
Jan 16 '07 #6
gyung
21
I had some trouble with this before. Here's an example of an AJAX script I found and love to use. I use this for both PHP and ASP, and works in FF and IE.

In HTML/ASP/whatever page use:

Expand|Select|Wrap|Line Numbers
  1. <div id="busy_cage">&nbsp;</div>
  2. <div id="item_cage">&nbsp;</div>
  3.  
JS include below

Expand|Select|Wrap|Line Numbers
  1. /* The following function creates an XMLHttpRequest object... */
  2.  
  3. function createRequestObject(){
  4.     var request_o; //declare the variable to hold the object.
  5.     var browser = navigator.appName; //find the browser name
  6.     if(browser == "Microsoft Internet Explorer"){
  7.         /* Create the object using MSIE's method */
  8.         request_o = new ActiveXObject("Microsoft.XMLHTTP");
  9.     }else{
  10.         /* Create the object using other browser's method */
  11.         request_o = new XMLHttpRequest();
  12.     }
  13.     return request_o; //return the object
  14. }
  15.  
  16. /* You can get more specific with version information by using 
  17.     parseInt(navigator.appVersion)
  18.     Which will extract an integer value containing the version 
  19.     of the browser being used.
  20. */
  21. /* The variable http will hold our new XMLHttpRequest object. */
  22. var http = createRequestObject(); 
  23.  
  24. /* Function called to get the product categories list */
  25.  
  26. function getDBList(ID){
  27.     /* Create the request. The first argument to the open function is the method (POST/GET),
  28.         and the second argument is the url... 
  29.         document contains references to all items on the page
  30.         We can reference document.form_category_select.select_category_select and we will         
  31.         be referencing the dropdown list. The selectedIndex property will give us the 
  32.         index of the selected item. 
  33.     */
  34.  
  35.     http.open('get', '../includes/productList.asp?ID=' + ID);
  36.     /* Define a function to call once a response has been received. This will be our
  37.         handleProductCategories function that we define below. */
  38.     http.onreadystatechange = handleProducts; 
  39.     /* Send the data. We use something other than null when we are sending using the POST
  40.         method. */
  41.     http.send(null);
  42. }
  43. function handleProducts(){
  44.     /* Make sure that the transaction has finished. The XMLHttpRequest object 
  45.         has a property called readyState with several states:
  46.         0: Uninitialized
  47.         1: Loading
  48.         2: Loaded
  49.         3: Interactive
  50.         4: Finished */
  51.     if(http.readyState == 1){
  52.  
  53.         document.getElementById('busy_cage').innerHTML = '<br /><img src="../img/busy.gif">';
  54.         document.getElementById('item_cage').innerHTML = '<br />Loading...';
  55.     }
  56.     if(http.readyState == 4){ //Finished loading the response
  57.         /* We have got the response from the server-side script,
  58.             let's see just what it was. using the responseText property of 
  59.             the XMLHttpRequest object. */
  60.         var response = http.responseText;
  61.         /* And now we want to change the product_categories <div> content.
  62.             we do this using an ability to get/change the content of a page element 
  63.             that we can find: innerHTML. */
  64.         getDBList2(0);
  65.         document.getElementById('busy_cage').innerHTML = '<br />&nbsp;';
  66.  
  67.         document.getElementById('item_cage').innerHTML = response;
  68.     }
  69. }
You also need a seperate page to process the request. I used, for example: productList.asp?ID=ID

Then you pass in the value with this. I used a select statement with multiple cages:

Expand|Select|Wrap|Line Numbers
  1. <select name="series" id="series" class="comboBox" onchange="getDBList(document.productSelect.series.options[document.productSelect.series.selectedIndex].value);">whatever</select>
Hope this kinda helps. Sorry it's so messy.
Jan 18 '07 #7
Frinavale
9,735 Expert Mod 8TB
I had some trouble with this before. Here's an example of an AJAX script I found and love to use. I use this for both PHP and ASP, and works in FF and IE.
...
Hope this kinda helps. Sorry it's so messy.
Thank you for the suggestion it was a great help.

I ended up creating a web page that uses a variation on what you supplied and called an asp that simply loops for 20 seconds to test that it works.

I haven't tested it in my main project yet because I'm still not confident enough with it to do so since I have a slight problem.

My test page will display the gif (and have it run perfectly in all browsers) and a "loading..." message while the page is waiting for the server to finish its loop (for 20seconds)...when the server's done the image is deleted and a "finished loading" message is inserted.

My problem is that it will only do this the first time I click the button.

Could someone please explain to me what I'm doing wrong?

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <title>Ajax learning</title>
  6. <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
  7. <body>
  8.  
  9. <script type="text/javascript">
  10.  
  11.   function ajaxFunction()
  12.   {
  13.    try
  14.    {
  15.      // Firefox, Opera 8.0+, Safari
  16.      return new XMLHttpRequest();
  17.    }
  18.    catch (e)
  19.    {
  20.    // Internet Explorer
  21.    try
  22.      {
  23.        return new ActiveXObject("Msxml2.XMLHTTP");
  24.      }
  25.    catch (e)
  26.      {
  27.      try
  28.        {
  29.          return new ActiveXObject("Microsoft.XMLHTTP");
  30.        }
  31.      catch (e)
  32.        {
  33.          alert("Your browser does not support AJAX!");
  34.          return null;
  35.        }
  36.      }
  37.    }
  38.  }
  39.  var xmlHttp=ajaxFunction();
  40.  function go()
  41.  {    
  42.     xmlHttp.open('get','http://myTestServer/AjaxTest/AjaxTest.asp');
  43.     xmlHttp.send(null);
  44.  }
  45.  xmlHttp.onreadystatechange=function()
  46.  {    
  47.     if(xmlHttp.readyState == 1)
  48.     {    document.getElementById('busy_cage').innerHTML = '<br /><img src="Email.gif" />';
  49.         document.getElementById('item_cage').innerHTML = '<br />Loading...';
  50.     }
  51.     if(xmlHttp.readyState == 4)
  52.     { //Finished loading the response
  53.         document.getElementById('busy_cage').innerHTML = '<br />&nbsp;';
  54.         document.getElementById('item_cage').innerHTML = '<br />Finished Loading';
  55.     }
  56.    }
  57. </script>
  58.     <form name="form1" method="post" action="http://myTestServer/AjaxTest/AjaxTest.asp" id="form1">
  59.         <div id='busy_cage' name='busy_cage'></div>
  60.         <div id='item_cage' name='item_cage'></div>
  61.         <input type="button" value="Test" id="Button1" onclick="go();"/>
  62.     </form>
  63.  
  64. </body>
  65. </html>
  66.  
The asp I'm using is:

Expand|Select|Wrap|Line Numbers
  1. <%  Response.Buffer = true 
  2.  
  3. Function WaitFor(SecDelay) 
  4.     timeStart = Timer() 
  5.     timeEnd = timeStart + SecDelay 
  6.     i = SecDelay 
  7.     Do While timeStart < timeEnd 
  8.         If i = Int(timeEnd) - Int(timeStart) Then 
  9.         Msg = Msg & i 
  10.         If i <> 0 Then Msg = Msg & ", " 
  11.         If ShowMsg = 1 Then Response.Write Msg 
  12.          Response.Flush() 
  13.        Msg = "" 
  14.         i = i - 1 
  15.         End if 
  16.         timeStart = Timer() 
  17.     Loop 
  18.  
  19.  
  20. End Function 
  21.  
  22. Call WaitFor(20) 
  23. %>
  24.  
Thanks again for the help!

-Frinny

P.S I'm hoping someone will move this tread to the Ajax/JavaScript section.
Jan 18 '07 #8
Frinavale
9,735 Expert Mod 8TB
Hey there,

I forgot to add in the last post that this doesn't work in Firefox either.
Is there a setting or something that I need to enable for Ajax to work with it?

Thanks
-Frinny
Jan 18 '07 #9
gyung
21
Mine works fine in FF. Anyway did you try adding "no-cache" to the headers? I had a similar problem before, which I posted about.

Expand|Select|Wrap|Line Numbers
  1. Response.Expires = -1
  2.     Response.AddHeader "Cache-Control", "no-cache"
  3.     Response.AddHeader "Cache-Control", "private"
  4.     Response.AddHeader "Cache-Control", "no-store"
  5.     Response.AddHeader "Cache-Control", "must-revalidate"
  6.     Response.AddHeader "Cache-Control", "max-stale=0"
  7.     Response.AddHeader "Cache-Control", "post-check=0"
  8.     Response.AddHeader "Cache-Control", "pre-check=0"
  9.     Response.AddHeader "Pragma", "no-cache"
  10.     Response.AddHeader "Keep-Alive", "timeout=3, max=993"
  11.     Response.AddHeader "Expires", "Sun, 08 May 1983 05:00:00 GMT"
Btw you might also need to call the function first inside the <div></div>. I forgot to mention that. I had trouble with it before too =X

If that doesn't work, I'm not sure, i just guess and check myself usually, or google =P
Jan 19 '07 #10
Frinavale
9,735 Expert Mod 8TB
Mine works fine in FF. Anyway did you try adding "no-cache" to the headers? I had a similar problem before, which I posted about.
...
Btw you might also need to call the function first inside the <div></div>. I forgot to mention that. I had trouble with it before too =X

If that doesn't work, I'm not sure, i just guess and check myself usually, or google =P
Thanks for your help Gyung!

I actually just found out about the no-cache header doing more research into Ajax.

I ended up changing my whole script to try and get things to work in Firefox. I'm getting an exception: "Permission denied to call method XMLHttpRequest.open"

I've made sure that I have my permissions set properly for the asp...and I'm able to call it from both IE and Opera. I've also made sure that I've used the exact domain name in the call.

I'm not sure what else to try.

My new and improved test web page is:
Expand|Select|Wrap|Line Numbers
  1. <HTML>
  2. <HEAD>
  3.     <TITLE></TITLE>
  4.     <META HTTP-EQUIV="Content-Type" content="text/html; charset=UTF-8">
  5. </HEAD>
  6. <BODY>
  7.     <script language="javascript">
  8.         function makeRequest(url) 
  9.         {   var http_request = false;
  10.             if (window.XMLHttpRequest) { // Mozilla, Safari, ...
  11.                 http_request = new XMLHttpRequest();
  12.                 if (http_request.overrideMimeType) {
  13.                     http_request.overrideMimeType('text/xml');
  14.                 }
  15.             } else if (window.ActiveXObject) { // IE
  16.                 try {
  17.                     http_request = new ActiveXObject("Msxml2.XMLHTTP");
  18.                 } catch (e) {
  19.                     try {
  20.                         http_request = new ActiveXObject("Microsoft.XMLHTTP");
  21.                     } catch (e) {}
  22.                 }
  23.             }
  24.  
  25.             if (!http_request) {
  26.                 alert('Cannot create an XMLHTTP instance');
  27.                 return false;
  28.             }
  29.  
  30.             http_request.onreadystatechange = function() { alertContents(http_request); };
  31.             try
  32.             {
  33.                 http_request.open('GET', url, true);
  34.                 http_request.send(null);
  35.             }
  36.             catch(e)
  37.             {
  38.                 alert("An excetption has occurred: "+e);
  39.             }
  40.         }
  41.         function alertContents(http_request)
  42.         {    if(http_request.readyState == 1)
  43.             {    document.getElementById('busy_cage').innerHTML = "<img src='Email.gif' >";
  44.                 document.getElementById('item_cage').innerHTML = '<br />Loading...';
  45.             }
  46.             else if (http_request.readyState == 4) {
  47.                 document.getElementById('busy_cage').innerHTML = '<br />&nbsp;';
  48.                 document.getElementById('item_cage').innerHTML = '<br />Finished Loading';
  49.                 try
  50.                 {   if (http_request.status == 200) {
  51.                         alert(http_request.responseText);
  52.                     } else {
  53.                         alert('There was a problem with the request.');
  54.                     }
  55.                     btn.disabled=false;
  56.                 }catch(e)
  57.                 {    btn.disabled=false;
  58.                     alert("An error occrred:"+e.description);
  59.                 }
  60.             }
  61.          }      
  62.     </script>
  63.  
  64.     <div id='busy_cage'><img src="BlankEmail.jpg" ></div>
  65.     <div id='item_cage'><br></div>
  66.     <input type='button'  id="btn" onclick="makeRequest('http://DevelopmentServer/AjaxTest/AjaxTest.asp');btn.disabled=true;" value ='Make a request' >
  67. </BODY>
  68. </HTML>
  69.  
And my new and improved asp page is:
Expand|Select|Wrap|Line Numbers
  1. <%  Response.Buffer = true 
  2.     Response.Expires=-1
  3.     response.CacheControl="no-cache"
  4.  
  5.  
  6.     Function WaitFor(SecDelay) 
  7.         timeStart = Timer() 
  8.         timeEnd = timeStart + SecDelay 
  9.         i = SecDelay 
  10.         Do While timeStart < timeEnd 
  11.             If i = Int(timeEnd) - Int(timeStart) Then 
  12.                 Msg = Msg & i 
  13.                 If i <> 0 Then Msg = Msg & ", " 
  14.                 If ShowMsg = 1 Then Response.Write Msg 
  15.                 i = i - 1 
  16.             End if 
  17.             timeStart = Timer() 
  18.         Loop 
  19.         Response.Write("The time delay has finished")
  20.     End Function 
  21.  Call WaitFor(10) 
  22. %>
  23.  
Does anyone know why I might be getting a permissions error?

Thanks for all the help! I would never have thought of using Ajax if it weren't for you.

-Frinny
Jan 19 '07 #11
gyung
21
I did some research and borrowed some more code. I read that you shouldn't request the browser name b/c it can be faked, so I followed W3Schools' example which is similar to yours, and modified my code to this for the script I was using:

Expand|Select|Wrap|Line Numbers
  1. function createRequestObject()
  2.   {  var xmlHttp;
  3.   try
  4.     {    // Firefox, Opera 8.0+, Safari    
  5.         xmlHttp = new XMLHttpRequest();    }
  6.   catch (e)
  7.     {    // Internet Explorer    
  8.     try
  9.       {      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");      }
  10.     catch (e)
  11.       {      try
  12.         {        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");        }
  13.       catch (e)
  14.         {        alert("Your browser does not support AJAX!");        return false;        }      
  15.         }   
  16.     }
  17.         return xmlHttp;
  18.     }
Sorry I'm not good at JS. I tend to look at code at modify it so it works for me, so this is how it did it this time. You may consider posting in the JS/AJAX section if you haven't, maybe someone more familiar with it can help you there. Good luck :D
Jan 22 '07 #12
gyung
21
Oh...right, the moderators apparently moved the thread, but it's still in ASP for me.

And I remembered something about cross-site security. Maybe you are doing it by accident somewhere, but that won't work. Just fyi
Jan 22 '07 #13
Frinavale
9,735 Expert Mod 8TB
I did some research and borrowed some more code. I read that you shouldn't request the browser name b/c it can be faked, so I followed W3Schools' example which is similar to yours, and modified my code to this for the script I was using:
...

Sorry I'm not good at JS. I tend to look at code at modify it so it works for me, so this is how it did it this time. You may consider posting in the JS/AJAX section if you haven't, maybe someone more familiar with it can help you there. Good luck :D
Thanks alot for the tip. I didn't know that and will have to watch for it in the future!

And I remembered something about cross-site security. Maybe you are doing it by accident somewhere, but that won't work. Just fyi
Yeah I read about it and it fixed the problem.
I finally got it work earlier today.

Thanks a lot for your help.

I just downloaded ASP.NET Ajax stuff today and can't wait to try it out. I haven't been this excited since my first "hello world" program!


:):):)

-Frinny
Jan 23 '07 #14
iam_clint
1,208 Expert 1GB
Hey guys i just had a similar problems i wanted to do on one of my sites



I figured out my own solution to it without AJAX using strictly Javascript...


If you set the source after the page is trying to load to the next screen

aka a window.setTimeout after they click the button the image will then run through its animation


so basicly i have a button

onclick="pleasewait(0, 1, 'black'); window.location='blah.asp';"

this calls my pleasewait function which sets a timeout to display my hidden div with the img -- at this point the image becomes visible but no animation now all you have todo is reset the SRC attribute of the image and wam you have animated gif while page transition.
Jan 29 '07 #15
Frinavale
9,735 Expert Mod 8TB
Hey guys i just had a similar problems i wanted to do on one of my sites

I figured out my own solution to it without AJAX using strictly Javascript...
If you set the source after the page is trying to load to the next screen
aka a window.setTimeout after they click the button the image will then run through its animation
so basicly i have a button

onclick="pleasewait(0, 1, 'black'); window.location='blah.asp';"

this calls my pleasewait function which sets a timeout to display my hidden div with the img -- at this point the image becomes visible but no animation now all you have todo is reset the SRC attribute of the image and wam you have animated gif while page transition.
I'm not sure what you mean by the timeout thing?
My function resets the src of the image but doesn't use a timeout....

Right now I'm not using Ajax in my project because I'm still learning how to use ASP.NET Ajax....

The javascript functions I'm currently using are:

Expand|Select|Wrap|Line Numbers
  1. <script type='text/javascript' language='JavaScript'>
  2.  
  3. <!--
  4.      function processingMessageOff() {
  5.        document.img_processing.src='Images/BlankProcessing.JPG';
  6.      }
  7.  // -->
  8.  
  9. </script>
  10.  
  11. <script type='text/javascript' language='JavaScript'>
  12.  
  13. <!--
  14.      function processingMessageOn() {
  15.        document.img_processing.src='Images/Processing.gif';
  16.      }
  17.  // -->
  18.  
  19. </script>
  20.  
So basically the processingMessageOff() is called to simply show a blank picture and when the button is clicked the processingMessageOn() function is called which changes the src of the image to be that of the Processing.Gif.

This solution doesn't work in IE6...

Is this what you mean by changing the src?
How does the timeout effect anything?

I'm just not quite clear on what you're trying to say. Maybe post the code you used for the pleaseWait() function you were describing?

Thanks for your help though!

-Frinny
Jan 30 '07 #16
iam_clint
1,208 Expert 1GB
the timeout affects it by waiting till the other page starts to load before changing the SRC of the image by giving it alittle bit of delay this method worked for both IE and FF.
Jan 30 '07 #17
iam_clint
1,208 Expert 1GB
The Javascript I use
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function pwait(count, co, color) {
  3.  if (count == 1) { document.getElementById("pwimg").src = "images/pwait.gif"; }
  4.  //border-top: solid 2px black; border-bottom: solid 2px black; border-right: solid 2px black; border-left: solid 2px black;
  5.  var ftable = document.getElementById("pwtable");
  6.  if (co == 1) {
  7.   ftable.style.borderTop = "solid 2px "+color;
  8.   ftable.style.borderBottom = "solid 2px black";
  9.   ftable.style.borderLeft = "solid 2px black";
  10.   ftable.style.borderRight = "solid 2px black";
  11.  }
  12.  if (co == 2) {
  13.   ftable.style.borderTop = "solid 2px black";
  14.   ftable.style.borderBottom = "solid 2px black";
  15.   ftable.style.borderLeft = "solid 2px "+color;
  16.   ftable.style.borderRight = "solid 2px black";
  17.  }
  18.  if (co == 3) {
  19.   ftable.style.borderTop = "solid 2px black";
  20.   ftable.style.borderBottom = "solid 2px "+color;
  21.   ftable.style.borderLeft = "solid 2px black";
  22.   ftable.style.borderRight = "solid 2px black";
  23.  }
  24.  if (co == 4) { 
  25.   ftable.style.borderTop = "solid 2px black";
  26.   ftable.style.borderBottom = "solid 2px black";
  27.   ftable.style.borderLeft = "solid 2px black";
  28.   ftable.style.borderRight = "solid 2px "+color;
  29.   co = 0; 
  30.  }
  31.  document.getElementById("pleasewait").style.visibility = "visible";
  32.     document.getElementById("pleasewait").style.top = document.body.scrollTop+document.documentElement.scrollTop+200;
  33.     document.getElementById("pleasewait").style.left = document.body.scrollLeft+document.documentElement.scrollLeft+500;
  34.  tmp = document.getElementById("pwait").innerHTML;
  35.  if (tmp == "&nbsp;") {
  36.   document.getElementById("pwait").innerHTML = ".";
  37.  }
  38.  if (tmp == ".") {
  39.   document.getElementById("pwait").innerHTML = "..";
  40.  }
  41.  if (tmp == "..") {
  42.   document.getElementById("pwait").innerHTML = "...";
  43.  }
  44.  if (tmp == "...") {
  45.   document.getElementById("pwait").innerHTML = "&nbsp;";
  46.  }
  47.  co = co + 1;
  48.  count = count + 1;
  49.  var pwaitint = window.setTimeout("pwait("+count+", "+co+", '"+color+"')", 200);
  50. }  
  51. </script>
  52.  
The Div I Use.
Expand|Select|Wrap|Line Numbers
  1. <div id="pleasewait" style="position: absolute; top: 200; left: 400; width: 180; height: 60; visibility: hidden;"><table width="100%" height="100%" bgcolor="white" style="border-top: solid 2px black; border-bottom: solid 2px black; border-right: solid 2px black; border-left: solid 2px black;" id="pwtable"><tr><td><img src="/images/pwait.gif" id="pwimg"><td width="70%" align="right" style="font-weight: 800;">Please Wait<td id="pwait" width="30%" align="left" style="font-weight: 800;">&nbsp;</table></div>
  2.  
When I call it
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function addcart() {
  3. var parts = document.getElementsByName("nparts");
  4. var mfgs = document.getElementsByName("suplier");
  5. var options = document.getElementsByName("option");
  6. var qstring = ""
  7. for (i=0; i<=options.length-1; i++) {
  8. if (options[i].checked) {
  9. qstring = qstring+"&nparts="+parts[i].value+"&suplier="+mfgs[i].value+"&qty=1"
  10. }
  11. }
  12. if (qstring!="") {
  13. pwait(0, 1, 'black');
  14. document.getElementById("favadd").disabled = true;
  15. window.location = "cart_add.asp?val=1"+qstring
  16. } else {
  17. alert("You didn't mark anything to be added!");
  18. }
  19. }
  20. </script>
  21.  
Cart add redirects you to cart_view, cart_view takes awhile to load due to it using ajax to query a database located on someone elses server to check stock levels and things like that.
Jan 30 '07 #18
Frinavale
9,735 Expert Mod 8TB
...
Cart add redirects you to cart_view, cart_view takes awhile to load due to it using ajax to query a database located on someone elses server to check stock levels and things like that.
Hmm...it didn't seem to work....
Maybe because its not waiting for the "next" page to load...its waiting for this one to get back to itself?
Jan 31 '07 #19
iam_clint
1,208 Expert 1GB
have you tried to call my pwait(0, 1, 'black');

function
Jan 31 '07 #20
Frinavale
9,735 Expert Mod 8TB
have you tried to call my pwait(0, 1, 'black');

function
Update: your pwait works fine. The Gif is kept running because it is reloaded in the loop.

Thanks iam_clint!
Jan 31 '08 #21

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Maxim | last post by:
I am wondering if anyone could suggest come performance improvements for processing a very large file. THe processing taking place here is on 30-50MB chunks of the file. Performance is...
6
by: Shawn Regan | last post by:
Hello, What is the best practice to show a window/form of some animation while processing is going on in the back ground. I want the user to see something while some processing is taking...
5
by: Bob | last post by:
I've got a .NET Framework V1.1 web service running on a Windows 2003 Server that has 2 web methods that are called from a web application on the same server. One is a fire-and-forget method that...
4
by: hzgt9b | last post by:
Using VB .NET 2003, I have a windows application that performs a series of file actions (copy, move, delete) but the actions are completing before the window is painted on the screen... how can I...
5
by: JasonDamianUs | last post by:
Hello all, I am trying to write a simple PHP script to process a form.. the function seems to be working fine // subscriber is the users email in the form if (( $subscriber ) && ($_SERVER ==...
14
by: Dave Booker | last post by:
I'm doing some analysis that is readily broken up into many independent pieces, on a multicore machine. I thought it would be best to just queue like 1000 of these pieces in the ThreadPool, and...
2
by: David F | last post by:
Hello, I have what seems like a simple left join query, but Access returns results like it's an inner join. I've tried numerous combinations without success. I have a table (ProjectList)...
14
by: Abhishek Bhatt | last post by:
The data is transferred from one table to another when user clicks on a button on the screen. The transfer takes approax 10-15 seconds. During this time I am able to move the mouse but not able to...
3
by: The Frog | last post by:
Hi everyone, I am trying to refine some ADO code that is used to extract data from excel spreadsheets and do a simple ETL type process to place the data into a table. The code works fine and is...
1
Dormilich
by: Dormilich | last post by:
Hi, I'm running into a problem with the <xsl:processing-instruction> element (Sablotron). purpose: I generate a xhtml fragment from a xml file via xslt. This is printed (echo) to the output...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.