Firefox perfect, problems with IE

Discussion in 'Javascript' started by edfialk, May 23, 2007.

  1. edfialk

    edfialk Guest

    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
    edfialk, May 23, 2007
    #1
    1. Advertising

  2. edfialk

    RobG Guest

    On May 24, 6:45 am, edfialk <> 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/c...for attachEvent&rnum=1&hl=en#93561d5a2ebdb4aa
    >


    --
    Rob
    RobG, May 24, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hitesh Panchal

    Not Getting perfect path

    Hitesh Panchal, Mar 3, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    325
    Mohamed El Ashmawy
    Mar 3, 2004
  2. =?Utf-8?B?QW5keQ==?=

    How can I perfect the look of my asp.net site?

    =?Utf-8?B?QW5keQ==?=, May 23, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    443
    Kevin Spencer
    May 23, 2005
  3. Replies:
    0
    Views:
    8,299
  4. Terrence Cooter

    PERFECT REIGN WHOIS DATA IS BOGUS

    Terrence Cooter, Sep 28, 2005, in forum: HTML
    Replies:
    11
    Views:
    868
    Tyrone M. Pierce
    Sep 30, 2005
  5. word9smith

    Word Perfect 11 as xml editor

    word9smith, Feb 2, 2005, in forum: XML
    Replies:
    2
    Views:
    390
    Peter Flynn
    Feb 4, 2005
Loading...

Share This Page