Changeset 5947


Ignore:
Timestamp:
Feb 6, 2012, 3:12:05 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #1660: Internet Explorer 9 won't open popup windows

I think this fixes the problems with IE9. I have not been able to see the issue after the changes. With the old code it usually possible to see the problem withing 5-10 clicks. The fixes include:

  • Always use the code in the top-level window (frameset) to open popup windows. This get rid of the closed-parent problem which seems to be a possible cause. But we still need to use the true parent window since a lot of popup windows uses the window.opener property to communicate values back and forth.


  • Check the URL length before opening a blank window. If the POST form is not needed we simply open the window with the correct URL to begin with. If a POST form is needed we open a window with a real URL referencing a blank window. This should hopefully get rid of cross-site-scripting issues.


  • Use exception handling when getting old popup window information. If we can't access the information the old popup is probably already closed and the code can at least continue and open a new popup.
Location:
branches/3.0-stable/www
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0-stable/www/include/scripts/main.js

    r5722 r5947  
    100100    @param options Specifies options for the decoration of the window as defined
    101101      by the JavaScript window.open() method
     102    @param parentWin The window object to use when calling open(). If not given
     103      the current window is used
    102104    @see http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/window.html#1202731
    103105  */
    104   this.openPopup = function(url, name, width, height, options)
    105   {
     106  this.openPopup = function(url, name, width, height, options, parentWin)
     107  {
     108    if (!parentWin) parentWin = window;
     109    if (window.top != window && window.top.Main)
     110    {
     111      window.top.Main.openPopup(url, name, width, height, options, parentWin);
     112      return;
     113    }
     114   
    106115    // Rescale the width and height
    107116    var scale = getScale();
     
    113122      have different properties for the width and height.
    114123    */
    115     var wTop = window.screenY;
    116     if (wTop == undefined) wTop = window.screenTop;
     124    var wTop = window.top.screenY;
     125    if (wTop == undefined) wTop = window.top.screenTop;
    117126    if (wTop == undefined) wTop = 0;
    118127 
    119     var wLeft = window.screenX;
    120     if (wLeft == undefined) wLeft = window.screenLeft;
     128    var wLeft = window.top.screenX;
     129    if (wLeft == undefined) wLeft = window.top.screenLeft;
    121130    if (wLeft == undefined) wLeft = 0;
    122131 
    123     var wHeight = this.getWindowHeight();
    124     var wWidth = this.getWindowWidth();
     132    var wHeight = Main.getWindowHeight(window.top);
     133    var wWidth = Main.getWindowWidth(window.top);
    125134   
    126135    var top = Math.ceil(wTop+(wHeight-height) / 2);
     
    131140    options = "top="+top+",left="+left+",width="+width+",height="+height+"," + options;
    132141
    133     var newWin = this.getPageValue('open.windows', name);
     142    var newWin = Main.getPageValue('open.windows', name);
    134143    if (newWin && !newWin.closed)
    135144    {
     
    143152      url += '&warnIfOpen=0';
    144153    }
    145     var newWin = window.open('', name, options);
    146     this.setPageValue('open.windows', name, newWin);
    147     Main.safeSetLocation(url, newWin, true);
     154    if (Main.isTooLongURL(url))
     155    {
     156      newWin = window.open(getRoot()+'blank.jsp', name, options);
     157      Main.safeSetLocation(url, newWin, true);
     158    }
     159    else
     160    {
     161      newWin = parentWin.open(url, name, options);
     162    }
     163    Main.setPageValue('open.windows', name, newWin);
    148164    setTimeout("Main.focusWindow('" + name + "')", 100);
    149165  }
     
    811827    if (!win) win = window;
    812828    var postform;
    813     if (window.getMaxUrlLength && url.length > window.getMaxUrlLength())
     829    if (this.isTooLongURL(url))
    814830    {
    815831      postform = this.convertToPostForm(url, win);
     
    828844      win.document.location.href = url;
    829845    }
     846  }
     847 
     848  /*
     849    Check if the URL is longer than the configured max URL length.
     850  */
     851  this.isTooLongURL = function(url)
     852  {
     853    return window.getMaxUrlLength && url.length > window.getMaxUrlLength();
    830854  }
    831855 
     
    887911  this.getPageValue = function(page, key)
    888912  {
    889     if (!window.top.pageValues) return null;
    890     if (!window.top.pageValues[page]) return null;
    891     return window.top.pageValues[page][key];
     913    var value = null;
     914    try
     915    {
     916      if (window.top.pageValues && window.top.pageValues[page])
     917      {
     918        value = window.top.pageValues[page][key];
     919      }
     920    }
     921    catch (e)
     922    {
     923      value = null;
     924    }
     925    return value;
    892926  }
    893927
  • branches/3.0-stable/www/index.jsp

    r5484 r5947  
    3636SessionControl sc = Base.getSessionControl(pageContext, true);
    3737String ID = sc.getId();
     38request.setAttribute("ID", ID);
    3839%>
    3940<base:page type="frameset" title="">
Note: See TracChangeset for help on using the changeset viewer.