Recently, here at the ranch, we have been experiencing a few issues with Internet Explorer’s javascript functionality. It’s not that IE is doing anything wrong, but rather that it performs unexpectedly. When opening a new window in javascript [window.open()], the height and width dimensions are relative to the size of the canvas / stage / content area (depending on what discipline you are from), all commonly referred to as innerHeight and innerWidth. However, when you execute a resize function in javascript [window.resizeTo()], the height and width dimensions are relative to the size of the entire window, including any chrome, commonly referred to as outerHeight and outerWidth.
Thus, if you create a window (500px x 300px), then resize it to (505px x 305px), the window will actually get smaller, since the chrome adds more than 5 pixels to height and width.
The problem: SCOs (Courseware) can be of any size, depending on the specifications, requirements, and whims of the original clients and developers. To keep courses in their most visual-appealing state, we need to size the content window to precise innerHeight and innerWidth pixel dimensions. Due to our site’s design, the link that launches the Course Shell window has no idea what the size of the SCO is. The Course Shell (LMS) knows how big the SCO is, but it is loaded into the Course Shell window, which is obviously done after the window is created and initially sized. We need a way to size the window to content-dimensions after the window is created.
The catch: Internet Explorer has no native support for innerHeight and innerWidth, let alone a way to resize to those dimensions. Furthermore, the difference between the inner- and outer-dimensions due to window chrome can change from OS to OS and from theme to theme. For example, in Windows XP’s default “bubbly” themes, the title and status bars are much taller than in Windows “Classic” themes. Internet Explorer has no native way to identify the difference in inner- and outer-dimensions, making it difficult to resize to an inner size using an outer size command.
I hacked together some (perhaps mediocre, but still effective) javascript to resize a window to its inner dimensions rather than the outer dimensions, regardless of the amount of chrome that the OS adds.
HTML
<div id="resizeReference" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; z-index: -1;"> </div>
Javascript
function resizeWindow(iWidth, iHeight){ var resizeRef = document.getElementById('resizeReference'); var iOuterWidth = iWidth + 10; var iOuterHeight = iHeight + 29; if (resizeRef) { var iPreWidth = resizeRef.offsetWidth; var iPreHeight = resizeRef.offsetHeight; window.resizeTo(iPreWidth,iPreHeight); var iPostWidth = resizeRef.offsetWidth; var iPostHeight = resizeRef.offsetHeight; iOuterWidth = iWidth + (iPreWidth-iPostWidth); iOuterHeight = iHeight + (iPreHeight-iPostHeight); } window.resizeTo(iOuterWidth, iOuterHeight); }
The HTML tag creates a hidden DIV whose height and width match the window. This provides innerHeight and innerWidth. The JS takes the dimensions of that DIV and resizes the window to those measured dimensions. Since this transfers the inner-dimensions to the outer-dimensions, this provides the exact size of the window chrome. We can now resize to the input parameter height and width, plus the height and width of window chrome, to give us a resize to inner-dimensions.
Execute resizeWindow no sooner than below the closing Body tag, so that the DIV is rendered.
It is a bit of a hack, but it works for now.
Remember Me