Skip to main content
March 23, 2007
Question

Getting parent window to close

  • March 23, 2007
  • 3 replies
  • 561 views
Hello. I've imported my captivate file into my LMS, but it seems to open a parent window. I've inserted the window.close = function() as suggested, but can't get it to work. Am I putting the code in the worng place? Where exactly do I put the code?
Here is a copy of my existing code.....

<!-- saved from url=(0013)about:internet -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " http://www.w3.org/TR/html4/loose.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Section 1 - Basic skills</title>
<script src="standard.js" type="text/javascript"></script>
<script type="text/javascript" language="JavaScript">
var strURLFile = "part 1_skin.swf"; // Name of the flash file
var strExitFile = "exit.swf"; // Name of the flash file that can facilitate LMS termination
var strExitMessage = "Please remember to click the Exit button in the content, before closing the browser window. Press \"OK\" to continue."
var isMSIE = navigator.appName.indexOf("Microsoft") != -1;
var g_bFinishDone = "";
var AICC_URL="";
var AICC_SID="";
var strURLBase = "";
var strURLParams = "";
var varWindow = findAICCwindow(window);
var strURLFull = varWindow.document.location.toString();
var intTemp = strURLFull.indexOf("#");
if (intTemp == -1)
intTemp = strURLFull.indexOf("?");
if (intTemp > 0)
strURLParams = strURLFull.substring(intTemp + 1, strURLFull.length);
var strTemp = location.protocol.toUpperCase();
if (strTemp.indexOf("FILE") == -1)
var intTemp = location.pathname.lastIndexOf("/");
else if (isMSIE)
var intTemp = location.pathname.lastIndexOf("\\");
else
var intTemp = location.pathname.lastIndexOf("/");

if (intTemp != -1)
strURLBase = location.protocol + "//" + location.host + location.pathname.substring(0, intTemp + 1);
else
strURLBase = location.protocol + "//" + location.host + location.pathname;

strURLParams = (strURLParams==unescape(strURLParams)?escape(strURLParams):strURLParams);
strURLParams = (strURLParams==""?"":"?") + strURLParams;

if(strURLParams.length > 1 && strURLParams.charAt(0)=='?')
strTemp = strURLParams.substr(1);
var aryTemp = strTemp.split("&");
for(var intTemp=0;intTemp < aryTemp.length; intTemp++)
{
var strPair = aryTemp[intTemp].split("=");
if(strPair.length==2)
{
var strName=strPair[0].toUpperCase();
if(strName=='AICC_SID')
AICC_SID=strPair[1];
else if (strName=='AICC_URL')
AICC_URL=strPair[1];
}
}


function findAICCwindow(win)
{
// This is a simple mechanism to walk up a frameset tree to find the window with AICC parameters. This
// function should be modified, if the parameters are in a more complicated structure.
if(win.document.location.toString().toUpperCase().indexOf("AICC_URL") == -1)
{
if(win!=window.top)
{
win = (findAICCwindow(win.parent));
}
}
return win;
}


function setFinished(finished_bln)
{
g_bFinishDone = finished_bln;
}

function Finish()
{
// ExitAU
if(g_bFinishDone == false)
{
g_bFinishDone = true;
if (AICC_URL !="")
{
if (isMSIE)
{
window.frames[0].document.forms[0].submit();
var ms = (new Date()).getTime();
while ((new Date()).getTime()-ms < 1000)
window.status="posting to LMS...";
} else {
var w = varWindow.open("","mm_exitAU","top=4000,left=4000,scrollbars=no,directories=no,height=1,width=1,status=no,toolbar=no,menubar=no,location=no");
if (w==null)
{
document.write('<table border="0" cellpadding="7" cellspacing="7"> \n');
document.write(' <tr> \n');
document.write(' <td align="middle">');
writedocument('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase=" http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="1" height="1" align="middle"> \n'+
' <param name=movie value="' + strURLBase + strExitFile + strURLParams + '">\n'+
' <param name=quality value=high> \n'+
' <param name=menu value=false> \n'+
' <param name=loop value=0> \n'+
' <embed src="' + strURLBase + strExitFile + strURLParams + '" pluginspage="https://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" quality=high type="application/x-shockwave-flash" name="Captivate1" width="1" height="1" align="middle" swLiveConnect="true">\n'+
' </embed> \n'+
' </object>');
document.write('</td> \n');
document.write(' </tr> \n');
document.write('</table> \n');
alert(strExitMessage);
} else {
w.document.write("<html><head>"+"<script"+">function findAICCwindow(win){if(win.document.location.toString().toUpperCase().indexOf('AICC_URL') == -1) {if(win!=window.top){win = (findAICCwindow(win.parent));}}return win;}function exitAU() {var varWindow=findAICCwindow(window);window.document.forms[0].submit();varWindow.close();}</"+"script>"+
"</head>"+
"<body>"+
"<form action='"+unescape(AICC_URL)+"' method='post'>"+
"<input type='hidden' name='session_id' value='"+unescape(AICC_SID)+"'>"+
"<input type='hidden' name='version' value='3.5'>"+
"<input type='hidden' name='command' value='ExitAU'>"+
"</form>"+
"</body>"+
"</html>");
w.exitAU();
}
}
}
}
}
function isrc()
{
return '<HTML><head><script><'+'/script></head><body MARGINWIDTH="0" MARGINHEIGHT="0" LEFTMARGIN="0" RIGHTMARGIN="0" TOPMARGIN="0" BOTTOMMARGIN="0">'+
"<form action='"+unescape(AICC_URL)+"' method='post' name='brz' ><input type='hidden' name='session_id' value='"+unescape(AICC_SID)+"'/><input type='hidden' name='version' value='3.5'/><input type='hidden' name='command' value='ExitAU'/></form>"+
"</body></html>";
}
if (isMSIE) {
document.write('<iframe name="iframe" width="0" height="0" src="javascript:parent.isrc()"></iframe>');
}

</script>
</head>
<body bgcolor="#F5F4F1" onunload="Finish();">



<script type="text/javascript" language="JavaScript" name="cmifrag">
document.write('<center>');
document.write('<table border="0" cellpadding="7" cellspacing="7"> \n');
document.write(' <tr> \n');
document.write(' <td align="middle">');
writeDocument('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase=" http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" id="Captivate1" width="800" height="624" align="middle"> \n'+
' <param name=movie value="' + strURLBase + strURLFile + strURLParams + '">\n'+
' <param name=quality value=high> \n'+
' <param name=loop value=2> \n'+
' <embed src="' + strURLBase + strURLFile + strURLParams + '" pluginspage="https://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" quality=high type="application/x-shockwave-flash" name="Captivate1" width="800" height="624" align="middle" swLiveConnect="true">\n'+
' </embed> \n'+
' </object>');
document.write('</td> \n');
document.write(' </tr> \n');
document.write('</table> \n');
document.write('</center>');
</script>
</body>
</html>
    This topic has been closed for replies.

    3 replies

    March 26, 2007
    Thank you both for your advice,
    I will try out both solutions and report back on success.
    KCWebPlaza-5meuTi
    Inspiring
    March 25, 2007
    I believe you need to add "top" to your JavaScript function in the HTML page, such as "top.window". However, if you close any other HTML pages, the user will get a nag screen asking them something like, "Are you sure you want to close this window?"
    Inspiring
    March 23, 2007
    Hi Amanda BHCC,

    Are you calling the file as a function call within Captivate?

    In other words, in Captivate for a button or for the end of a project you have the oppertunith to select "execute javascript". Project Preferences -> Project End Options -> Action: Execute Javascript

    In the Window you get when you click the elipsis button (...) you should only call the function. The call would look something like this: javascript:MM_closeBrWindow();

    You don't actually put in the entire javascript in that window. Instead you put the full function in the head of the HTML document (or in a .js file that you connect to using a "include" reference at the head of the HTML page). You actually just call the function from Captivate.

    I do this kind of think all the time. As long as you just call the function and don't place the entire function in that window it should work. (Oh make sure you upload the include .js file if you use that method.)

    Does this help?

    TPK