Tuesday, May 3, 2011

popup blinks in ie8

Hi, all! We had discovered strange behaviour of popups in IE8. In IE7 and IE6 our popup looks like this:
alt text
But in IE8 it has strange border which "blinks" for 5-6 times and looks like this:
alt text
Code which is used for showing this popup:

Browser.prototype.showPopup = function(someHtml) {

  ...

  var popup = doc.parentWindow.createPopup();

  for(var n = 0; n < doc.styleSheets.length; n++) {
    popup.document.createStyleSheet(document.styleSheets[n].href);
  }

  popup.document.body.innerHTML = "<div style=\"width:100%;height:100%;overflow:auto\">" + someHtml + "</div>";

  popup.document.parentWindow.Form = Form;
  popup.document.attachEvent("onselectstart", IEOnSelectStart);
  popup.document.attachEvent("oncontextmenu", IEOnContextMenu);

  ...

  popup.show(x, y, width, height, ctl);
  doc.popup = popup;
}

What I researched:
1. I had tried to subscribe on onpropertychanged event. But it does not fired while border changes, whereas it works fine if I try to change this properties from code.
2. I had wrote simple watcher which each 100ms queries popup and dumps it properties. That is how I discovered that someone sets body.style.borderStyle to "inset" and after few seconds to outset(not a styleName).
3. Reviewed all out JavaScript code and didn't find any references on inset or outset values. I am on 99% sure that this is not our code changes the borders. Maybe it is some kind of IE security policy as a reaction on some our action.
Any ideas- what could cause such changes of the popup borders in IE8?

P.S. Also I cannot reproduce this issue outside of our environment.
P.P.S. Site in in trusted zone
P.P.P.S. IE mode is quirks P.P.P.P.S. Some popups on the same page works fine, but I cannot find the difference between them which could lead to such behaviour.

From stackoverflow
  • I had reproduced problem with this code:

    <script type="text/javascript" >
        document.showInnerPopup = function(){
            alert("Inner popup");
        }
    
        function btnOnClick(){
            var popup = document.parentWindow.createPopup();
            popup.document.body.innerHTML = "<div style=\"border: 1px solid red;width: 100%; height:100%\" id=\"popupDiv\" onclick=\"javascript:document.showInnerPopup(this,event)\">Click to show another popup</div>";
            popup.document.showInnerPopup = function(obj, evt) {
                var doc = evt.srcElement.ownerDocument;
    
                var popup = doc.parentWindow.createPopup();
                popup.document.body.innerHTML = "<div style=\"border: 1px solid green;width: 100%; height:100%\">Nested popup</div>"
                popup.show(10, -20, 150, 150, doc.body);
            }
    
            popup.show(10, -20, 100, 100, document.getElementById("btn"));
            document.btn = document.getElementById("btn");
            document.popup = popup;
        }
    </script>
    <input type="button" value="Show Popup" onclick="btnOnClick()" id="btn" />
    

    This behavior is because of IE setting “Allow script-initiated windows without size or position constraints” which by-default has value “Disable” even for trusted zone

  • Perhaps the IE dev team have decided to become good and make life hard on those who want to use popups :)

    horseman : IE dev team decided to make life hard on those who want to build rich interfaces. FYI: popups are used not only for injection and attacks :-)
    Robert Grant : Haha yeah - all those rich UIs that require popups to work. Better let the Google Maps/Gmail dev teams know so they can horribly break the UX in pursuit of this new definition of "rich" :p
  • I get a sort of blinking whenever I use Google in IE8 and place the mouse over the search entry field which prevents me from typing until I move the mouse away. But my cause was the Tweakui's 'activation follows mouse' X-Mouse feature. Yet with that feature off and hovering over the search there is still a 'Google Search' that blinks on and off.

    This is why I avoid IE. It's still so buggy. I don't care if tweakui is unsupported by MS. Why doesn't MS just rewrite IE altogether?

  • Thanks horseman. Your suggestion helped to resovle the issue we have with our system.

0 comments:

Post a Comment