Odd timing issue on IE10 (maybe others)

892
6
10-08-2014 03:56 AM
AdrianMarsden
Occasional Contributor III

exception in animation handler for:onAnimate

TypeError: Unable to get property 'width' of undefined or null reference

Hi

I have a site, it is accessed at times with URLs with parameters (default zoom, default layers, and stuff)

In IE if I go straight via a shortcut/hyperlink elsewhere I get

exception in animation handler for:onAnimate

TypeError: Unable to get property 'width' of undefined or null reference

In the IE debug window and something then goes splut and nothing loads.

I use the browser refresh and all is fine.  If I go to the URL bar in IE and hit enter it fails again

Tome, this looks like my init function isn't completing at the right time and various components haven't been loaded, but why this odd behaviour that it only fails when going there directly, and not on refresh?  It even works if I clear the cache before hitting refresh, so it isn't the fact that it loads the scripts locall;y, therefore faster.

Puzzled!

ACm

0 Kudos
6 Replies
KellyHutchins
Esri Frequent Contributor

Adrian,

Can you reproduce this with one of the samples? Or do you have a simple test case that shows the problem?

0 Kudos
AdrianMarsden
Occasional Contributor III

Not really, the code I have is quite complex.  I've just tested it on a public example of my site and it was fine.  Very strange.

0 Kudos
AdrianMarsden
Occasional Contributor III

A bit more digging (I'm not too good with the IE debug tools) the function that is throwing the first error is

                    _onZoomHandler: function(b, e, c) {

                        b = this._startRect;

                        var d = b.width * e,

                            f = b.height * e,

                            g = this._img,

                            h = a("ie");

                        g && (h && 8 > h ? k.set(g, {

                            left: b.left - (d - b.width) * (c.x - b.left) / b.width + "px",

                            top: b.top - (f - b.height) * (c.y - b.top) / b.height + "px",

                            zoom: e * b.zoom

                        }) : k.set(g, {

                            left: b.left - (d - b.width) * (c.x - b.left) / b.width + "px",

                            top: b.top - (f - b.height) * (c.y - b.top) / b.height + "px",

                            width: d + "px",

                            height: f + "px"

                        }))

                    },

the actual line is  03 above.

0 Kudos
KellyHutchins
Esri Frequent Contributor

What is your app doing when it loads the url params. Are you modifying the default extent using something like map.setExtent? If so try waiting for the response before continuing to modify the map.  For example:

map.setExtent(extent).then(function(){

     //do something here

});

AdrianMarsden
Occasional Contributor III

I'll give that a shot, but from testing yesterday it seemed that;

  • With any parameters I always get this error and then the app failed to load my TOC (Nliu's) fails to load only when URL is entered directly or from shortcut
  • A refresh works
  • Sometimes I get these errors without any URL parameters and TOC fails to load.

I've modenized my cade with the init code wrapped in a

require(["dojo/ready"], function (ready) {

    ready(1000, function () {

Rather than doing it the old way - this didn't work, but at least I have a bit mre control.

Cheers


ACM

0 Kudos
AdrianMarsden
Occasional Contributor III
0 Kudos