Hi Amy,
First of all, thank you for taking time to explore this, and test and propose a fix.
Unhappily, there appears to be even more twists in this than a Gordian knot, and I fear this is getting to be a very dark place.
I have taken your script (as attached to your post), and the following are the results I get – which are different from yours. First, I’ll just repeat my environment details:
- Moodle 2.1.1+ (Build 20110907 (2011070101.08)) updated today
- Two IIS7 servers: local on Vista Business SP2, remote on a dedicated Windows 2008 x64 Server Web Edition
- MySQL 5.5.14 and PHP 5.3.6
- Browsers: IE9, Firefox 6.0.1 with Firebug, Google Chrome with Firebug Lite
Issue 1: Different results: I repackaged the script attached to your post, and got identical results on both local and remote servers:
- IE9: Neither doClose() (your function) nor content.close_window(e) (my “solution”) close the SCORM player window.
- Google Chrome: Neither doClose() nor content.close_window(e) close the SCORM player window.
- Firefox: doClose() fails to close the SCORM player window, but content.close_window(e) does, just as described in my initial post.
Question: why does doClose() work in your environment, but not in mine? Are you on Linux? Do you use a Mac?
Question: why does Firefox close on a content.close_window(e) call, but IE9 and Chrome won't?
Issue 2: The “missing” semicolon: ECMA-262 (the specification for JavaScript) specifies “Automatic Semicolon Insertion” (ASI) which in effect means that semicolons are optional (except in a small number of extreme examples which may result in unexpected results). True, there is debate, and sometimes strong opinion, about whether programmers ”must” terminate statements with semicolons, but the fact is, javaScript interpreters are required to insert semicolons where appropriate, and I cannot image that the three browsers I use have got this wrong.
Question: Why does the addition of a semicolon as you describe throw an error for you?
Comment: Given ASI, the omission of a semicolon at that point should not be a problem, as indeed has been the case for several years using this particular bit of HTML/JS code in another LMS. As a corollary, why should its addition throw the error in your environment?
Also, after the preceding tests (Issue 1) I added a semicolon to the script you provided, and no error was observed in any of the three browsers (this was only checked on the local server).
Question: Why do you get an error, and I don't?
Issue 3: YUI: It may well be the case that YUI is not being used in /mod/scorm/player.js, but is certainly is before the actual SCO is called – even for this naively simple test SCO. After the player window is called by http://localhost/mod/scorm/player.php?scoid=636&cm=23¤torg=course1&display=popup, there are 31 requests recorded by Firebug before the SCO itself is called; of these, 20 requests are for JS, and of those 14 are to yui_combo functions. The list of these requests is attached for info (unfortunately the full names are truncated in the Firebug listing).
Question: Why do we need all this stuff? Why not just add a hidden frame containing the API into the source HTML, and send the page to the browser?
Issue 4: More YUI: The entire HTML script in SCOcloseTest.html is 828 characters (with comments removed). The actual browser window source code can then be inspected by right-clicking the page and selecting source code from the context menu. When delivered to the SCORM player window, the original 828 characters of source code is blown out to 21,621 characters, full of unintelligible (for me) YUI calls. That's 2,611% inflation!
Question: What on earth is going on here?
Amy, I’ll send you access details for my remote server so you can check this out, if you’d be so kind. I really would be interested in your take (and of course anyone else's).