Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Javascript / Client Side Development

Firefox perfect, problems with IE


Hello all, I have this web application up at http://niceguy.wustl.edu/NEISGEI/EmisComp.
It's for visually comparing emission data.

So, I added this nice loading animated gif to the maps to show users
that the image is still downloading (some data can take a couple of
minutes). I found the script somewhere on the web.

Unfortunately, it doesn't work in Internet Explorer (surprise...)

So, I have 3 maps, 3 loading gifs, 3 loading divs.  I'm only showing
the addLoadEvent function for one, but here's the script:

document.write('<div id="loading1"><img src="load.gif"></div>');
document.write('<div id="loading2"><img src="load.gif"></div>');
document.write('<div id="loading3"><img src="load.gif"></div>');

function addLoadEvent1(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }

}

addLoadEvent1(function() {
  document.getElementById("loading1").style.display="none";

});

Any ideas what the IE problem is?
Thanks!
-Ed
On May 24, 6:45 am, edfialk <edfi@gmail.com> wrote:

> Hello all, I have this web application up athttp://niceguy.wustl.edu/NEISGEI/EmisComp.
> It's for visually comparing emission data.

> So, I added this nice loading animated gif to the maps to show users
> that the image is still downloading (some data can take a couple of
> minutes). I found the script somewhere on the web.

> Unfortunately, it doesn't work in Internet Explorer (surprise...)

> So, I have 3 maps, 3 loading gifs, 3 loading divs.  I'm only showing
> the addLoadEvent function for one, but here's the script:

> document.write('<div id="loading1"><img src="load.gif"></div>');
> document.write('<div id="loading2"><img src="load.gif"></div>');
> document.write('<div id="loading3"><img src="load.gif"></div>');

It is more efficient to concatenate the strings and call
document.write once:

 document.write(
     '<div id="loading1"><img src="load.gif"></div>' +
     '<div id="loading2"><img src="load.gif"></div>' +
     '<div id="loading3"><img src="load.gif"></div>'
 );

> function addLoadEvent1(func) {
>   var oldonload = window.onload;
>   if (typeof window.onload != 'function') {
>     window.onload = func;
>   } else {
>     window.onload = function() {
>       if (oldonload) {
>         oldonload();
>       }
>       func();
>     }
>   }
> }

That is an old method, though still quite effective.  There are others
that use a mix of attachEvent and addEventListener (search the
archives[1]).  A better version of the above is:

  function addLoadEvent1(func) {
    var oldonload = window.onload;
    if (typeof oldonload == 'function') {
      window.onload = function(){
        oldonload();
        func();
      }
    } else {
      window.onload = func;
    }
  }

There is a minor issue that if used extensively, the closures that are
formed may consume more memory than you realise.  However, it may not
use much more than would have been consumed using addEventListener/
attachEvent, just be aware of it.

1. The following link has a good discussion:
<URL:
http://groups.google.com.au/group/comp.lang.javascript/browse_frm/thr...


--
Rob
Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc