none
I am using Internet explorer 11, the onresize event is happening continously over and over again. RRS feed

  • Question

  • What could be the reason for onresize event happening over and over again. This happens only in Internet explorer 11, the issue is not seen in internet explorer 9.
    Wednesday, December 7, 2016 7:20 AM

Answers

All replies

  • What could be the reason for onresize event happening over and over again. This happens only in Internet explorer 11, the issue is not seen in internet explorer 9.

    Hi Santhosdevangas 😎,

    I'm afraid we can currently only guess at the problem, we'd need a Minimal, Complete, and Verifiable example that includes sample data to be able to verify answers we'd give.

    Suggestions for asking a question on help forums

    Regards.

    Questions regarding Internet Explorer 8, 9 and 10 and Internet Explorer 11 for the IT Pro Audience. Topics covered are: Installation, Deployment, Configuration, Security, Group Policy, Management questions. If you are a consumer looking for answers or to raise a question, it's highly recommended you head on over to http://answers.microsoft.com/en-us


    Rob^_^

    Wednesday, December 7, 2016 2:43 PM
  • Sorry for less information earlier. Here is the small code snippet of what happening:

    Here is the code that calculates the height of the node(Iframe's HTML body is passed as a parameter).

    function myOnResize()
    {

            var style = DomGetStyle(node);
                
            var margin = DomGetStyleInt(style, "marginTop") + DomGetStyleInt(style, "marginBottom");

           if (node.tagName == "BODY" && DomIsStandard())
           {
                if (document.all)
               {
                    var border = DomGetStyleInt(style, "borderTopWidth") + DomGetStyleInt(style,          "borderBottomWidth");

                    return node.scrollHeight + margin + border;
               }

               if (DomIsQuirksMode())
                    return node.scrollHeight;
        }

        return node.scrollHeight + margin;

    }


    function DomGetStyle(node)
    {
        var style;
        if (document.all)
            style = node.currentStyle;
        else
            style = node.ownerDocument.defaultView.getComputedStyle(node, null);

        return style;
    }

    function DomGetStyleInt(style, attr)
    {
        var parsed = parseInt(style[attr]);
        return isNaN(parsed) ? 0 : parsed;
    }

    function DomIsStandard()
    {
        if (!document.all)
            return true;

        return (document.compatMode != "BackCompat");
    }

    function DomIsQuirksMode()
    {
        return (document.compatMode == "BackCompat");
    }

    Thursday, December 8, 2016 6:53 AM
  • Calling the following method to set the returned number as height.

    DomSetHeight(window.frameElement, number); is called

    DomSetHeight(node, h)
    {
        if (parseInt(h) != h)
        {
            node.style.height = h;
            return;
        }

        var style = DomGetStyle(node);
        var margin = DomGetStyleInt(style, "marginTop") + DomGetStyleInt(style, "marginBottom");

        if (DomIsStandard())
        {
            var border = DomGetStyleInt(style, "borderTopWidth") + DomGetStyleInt(style, "borderBottomWidth");
            var padding = DomGetStyleInt(style, "paddingTop") + DomGetStyleInt(style, "paddingBottom");
            node.style.height = Math.max(0, h - margin - border - padding) + "px";
        }
        else
        {
            node.style.height = Math.max(0, h - margin) + "px";
        }
    }



    Thursday, December 8, 2016 1:59 PM
  • Found out the root cause,

    The culprit is "node.scrollHeight" in Quirks mode, it is continuously increasing where as in other browsers it stays constant 292px(Internet explorer 9, Chrome and Firefox).

    I switched the document to Standard mode by adding "<!DOCTYPE html>" and now another issue happens where "node.scrollHeight" returns 278 no matter how much i reduce the browser window.


    Friday, December 9, 2016 4:55 AM
  • Excellent solution, it worked!!!

    I just added one like as follows

    // Do this to remove unwanted padding in IE.
        node.style.height = 0;

    Before reading the height.

    Friday, December 9, 2016 10:32 AM