1

I'm using a function to resize window when a popup is opened. It's supposed to calculate the coordinates of a table and open the popup according to it. (to avoid the popup being too small and needing to use scroll).

The problem is that when I test it in my local environment, it works fine, but when I test it running on another environment, it seems that it's not being applied (but I tested it from the same machine, using the same browser.) Do you have any idea of what could possibly be the problem? Here's my javascript function who does the resize:

function resizeWindowHeightForLittleRows(bottom){
    var tHeader = parseInt(document.getElementById('xtFzRow').style.height) + 
                  parseInt(document.getElementById('headerTable').clientHeight) +
                  28; /*Title Bar*/
    var isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
    var isFF = navigator.userAgent.indexOf("Firefox") > -1;
    var titleBarHeight = isChrome ? 40 : (isFF ? 55 : 20); 
    var tableHeight = parseInt(document.getElementById('xtFCInner').style.height) + titleBarHeight;
    var screenHeight = tHeader + tableHeight + bottom;
    var availHeight = screen.availHeight-100;
    window.resizeTo(screen.availWidth-100, screenHeight <= availHeight ? screenHeight : availHeight);

}

As I verified the same javascript is being applied in both cases and I tested from the same machine with the sabe browser, I have no idea what configuration (or something else) could be the cause of this issue. Any ideas I can try?

UPDATE: The problem is that my function is not considering if url bar is being displayed or not

I need to add in my resize function the verification if url bar is being displayed, to get the correct values when resizing it

periback2
  • 1,459
  • 4
  • 19
  • 36
  • Different browser versions maybe? Anyways, http://stackoverflow.com/questions/3641648/the-javascript-resizeto-function-not-working-in-chrome-and-opera and http://stackoverflow.com/questions/7602078/javascripts-window-resizeto-isnt-working – Ian Apr 15 '13 at 13:33
  • it cannot be.. I tested with the same browser.. I just change the url (localhost it works, but in another environment, it doesn't.. and the same javascript code is being applied... it's really weird) – periback2 Apr 15 '13 at 13:36
  • Same browser doesn't necessarily mean same version. But it's probably not the problem anyways. Did you check your browser console to see if there's any errors? – Ian Apr 15 '13 at 13:49
  • yes I did.. I found the problem, but I don't know the solution yet.. I'm not considering the url bar to set the size of popup, and in my local environment, it isn't being displayed, but when I test in another environment, it is.. so this is the problem! I'll edit the question and search for it – periback2 Apr 15 '13 at 14:24

1 Answers1

1

in FF and Chrome, you can use window.locationbar to check if it's visible or not, but this isn't implemented for IE.

My suggestion is to consider adding 30px more to the titlebarheight in your JavaScript function:

function resizeWindowHeightForLittleRows(bottom){
    var tHeader = parseInt(document.getElementById('xtFzRow').style.height) + 
              parseInt(document.getElementById('headerTable').clientHeight) +
              28; /*Title Bar*/
    var isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
    var isFF = navigator.userAgent.indexOf("Firefox") > -1;
    var titleBarHeight = isChrome ? 40 : (isFF ? 55 : 50);// adding 30px if it's not chrome or FF
    var tableHeight = parseInt(document.getElementById('xtFCInner').style.height) + titleBarHeight;
    var screenHeight = tHeader + tableHeight + bottom;
    var availHeight = screen.availHeight-100;
    window.resizeTo(screen.availWidth-100, screenHeight <= availHeight ? screenHeight : availHeight);
}
sergioviniciuss
  • 4,596
  • 3
  • 36
  • 50