Select to view content in your preferred language

How can I avoid the "invalid argument" error in IE8?

2072
1
Jump to solution
07-18-2014 11:20 AM
JuliaCarney
Deactivated User

Hello,

I've been struggling with this for two days, despite the fact that there is some documentation of this error out there. Until recently, I could load my map using IE8 fine, but now I'm getting an error "invalid argument" from the arcgis jsapi in IE8. Looking at this forum post‌ , I realized it was the same issue, except that in my case, I was passing negative values into that style function which was breaking IE8. I downloaded the arcgis jsapi and tried to fix line 136 like so:

d={cssFloat:1,styleFloat:1,"float":1};l.get=function(a,b){var f=n.byId(a),h=arguments.length;if(2==h&&"opacity"==b)return k(f);b=d?"cssFloat"in f.style?"cssFloat":"styleFloat":b;var m=l.getComputedStyle(f);return 1==h?m:e(f,b,m||f.style)};l.set=function(a,b,f){var e=n.byId(a),k=arguments.length,m="opacity"==b;b=d?"cssFloat"in e.style?"cssFloat":"styleFloat":b;console.log(f);console.log((typeof f==="string" && f.charAt(0)==="-")|| (typeof f!=="string" && typeof f!=="number"));if(3==k)return m?h(e,f):e.style=((typeof f==="string" && f.charAt(0)==="-")|| (typeof f!=="string" && typeof f!=="number")?'0px':f);for(var r in b)l.set(a,r,b);return l.getComputedStyle(e)};return l})},"dojo/dom-geometry":function(){define(["./sniff",

This did prevent the original error, but then an error occurred later in a similar line of code in something called vml.js, and I don't know where that file even is or where it's referenced. So I decided I'd like to try to fix this upstream instead, if possible. My map always used the jquery library without running into issues - in the attached html you'll see that I ordered my includes like so:

<script src="http://js.arcgis.com/3.9/"></script>

<script src="/eCNS/js/jquery.min.js"></script>

<script src="mapJS.js"></script>

I didn't use jquery as suggested here: Using jQuery | ArcGIS API for JavaScript‌, but it was working before regardless. One thing that has changed was the jquery library, which is why I was interested in whether that was issue. The jquery library we're using now is 1.11.1, and I believe that before it was 2.1.1, though I can't get that to work at all with my map now (may be a conflict with the overarching site's jquery. I don't even know if this is related to jquery, but if we can narrow that down to either being an issue or not, it would help.

Another complication with our site is that we load the map from a hidden iframe. This was consistently preventing the map from resizing itself properly, but it seemed to work reliably when we used the following code to handle window resizes.

    //resize map functions

    function resizeMapDiv() {

        var windowwidth = $(window).width();

        var windowheight = $(window).height();

        var newwidth = windowwidth - ($("#leftPane").width() + 20)

        var newheight = windowheight - ($("#header").height() + 20)

        $('#map').height(newheight).width(newwidth);

    }

    //was necessary to set a timer to get the map div to initialize to the correct size from the hidden iFrame

    var resizeTimeout;

    var mapLoaded = 0;

    $(window).resize(function () {

        if (iframeResizeComplete == 0) {

            iframeResizeComplete = 1;

            resizeTimeout = setTimeout(loadMapFncs, 700);

        } else if (iframeResizeComplete === 1 && mapLoaded === 1) {

            resizeMapDiv();

            map.resize();

            map.reposition();

        }

    });

So, I guess my questions are:

- could this be related to jquery?

- if I include jquery as a module, could that help?

- what other troubleshooting steps do you know that might work? I tried adapting this advice to my current versions, but I couldn't get it to work : IE bug using JSAPIv1.6 and BorderContainer

Thanks,

Jules

0 Kudos
1 Solution

Accepted Solutions
JuliaCarney
Deactivated User

Update:

What was happening was that when we tried to resize the map div when pressing the button to unhide the iframe and show the map, in IE8 only the window.resize event occurs a few times before the page is truly open somehow, and in that case the window height is 0. This meant that when we tried to manually resize the div relative to the window height, our map div had a negative sizing which was being passed back to the css. 

View solution in original post

0 Kudos
1 Reply
JuliaCarney
Deactivated User

Update:

What was happening was that when we tried to resize the map div when pressing the button to unhide the iframe and show the map, in IE8 only the window.resize event occurs a few times before the page is truly open somehow, and in that case the window height is 0. This meant that when we tried to manually resize the div relative to the window height, our map div had a negative sizing which was being passed back to the css. 

0 Kudos