Force window size hack

Why?

Some LMSs do not allow the configuration of a course launch window size. (Or, the users administering the LMS do not understand how to adjust those settings).

What?

The purpose of this hack is to attempt to force the window size of the course to a specific value.

Cautions?

  1. This is not supported uniformly by all browsers in all cases.
  2. This technique is considered malicious in many cases, so certain browsers disable it by default.
    1. Because most LMSs open courses in pop-up windows, using it may fly in most cases, but this will not work in LMSs that open the course in the same window that the LMS was in.
  1. This solution will not work for Multi-SCO courses, as our content is loaded into a frame inside the course interface hosted by the LMS. This interface controls the size of the course window, not the course. There should be settings for launch behaviour in the LMS.

How?

This code must be added to the javascript of your course index.html page:

 var suggestedWidth = 1024; //change this to the recommended width for the course var suggestedHeight = 768; //change this to the recommended height for the course  function handleWindowLoad(){  //Calculate the minimum value between the suggested width for the course and the max width of the users screen. We do this for height too.  var calculatedWidth = Math.min(suggestedWidth,screen.width);  var calculatedHeight = Math.min(suggestedHeight, screen.height);  //The calculated height is then used to avoid resizing the course window beyond the users screen.  window.resizeTo(calculatedWidth,calculatedHeight); } 

Note that you should change the suggestedWidth and suggestedHeight values to match those of your particular course.

The body tag inside the index.html file needs to be updated to have the handleWindowLoad() function called on it's onload event like so:

 <body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="handleWindowLoad()" onUnload="isLMSFinished()"> 

Note the settings for bgcolor, margins, and onUnload DO NOT need to be changed for your course to match the ones here.