Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Reload Page using Javascript

Participant ,
Jan 22, 2015 Jan 22, 2015

I developed a Captivate 8.01 project and I'm using Moodle as LMS.

I need to "Reload" the main web browser page when I Exit the project, so I tried using this JavaScript code: "location.reload(true);" but is not working.

Should I use the Captivate Common JS interface to run this code, and if true, how do I do that (how do I implement it)? Thank you.

2.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 22, 2015 Jan 22, 2015

What do you mean by the main web browser page?

Are you trying to get back to the course menu?

Where are you executing that code?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 22, 2015 Jan 22, 2015

Thanks for your reply.

My project is divided in two parts: Course and Exam (two separate project/SCORM files). My LMS shows two links (Course/Exam) in the course page, but the Exam link is not active until student finishes the course. Both, the Course and the Exam open in a separate browser window after clicking the link(s).

I set my Course project end options to "Close Project", so in the last slide of the course, a button "Exits" the course, and the course window closes.

The issue is, when student finishes the Course and exits, the LMS shows the original page with the Course/Exam links, but the Exam link will not be active until student Reloads the browser page. Then the browser page updates, and the Exam link is active (student can go to the exam.) So basically, I'm just trying to automatically reload the main page so the student doesn't have to.

I tried putting the code on an Advanced Action assigned to the Exit button of the last slide (with both, Exit and Reload code); also tried placing the code in the last-slide's On-Exit action, but it doesn't work. Browser page just doesn't reloads.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 22, 2015 Jan 22, 2015

We have the same type of issue sometimes just showing completion.

You could try executing some script attached to the body tag in the html page holding each Course.

<body onUnload="window.opener.location.reload();"


or

<body onUnload="window.opener.location.href = window.opener.location.href;"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 22, 2015 Jan 22, 2015

Since the course page is generated by Moodle, I'm not sure we can do that, will check.

My main issue was that maybe the way I'm setting the code is incorrect, because Captivate requires the use of the Common JS Interface for proper JavaScript operation. Don't understand how to set the code this way.

I can always ask students to press "F5" to reload, and the problem is fixed. Thanks for your help.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 22, 2015 Jan 22, 2015

I meant in the html page (index.htm) that Captivate generates.

I use my own SCORM functions, and this is set for courses running in a frame, but this is our exit code:

function exitCourse()

var api = getAPIHandle();
   var result = "false";

if (api != null)
{
  api.LMSSetValue("cmi.core.exit", "suspend");
   api.LMSFinish("");
  window.top.location="/learn6.asp?sessionid="+(getUrlVars()['sessionid'])+"&rootclass="+(getUrlVars()['rootclass'])+"&classid="+(getUrlVars()['classid'])+"&c=&courseid=0&mode=";
}
else
{
  var win = window.open("","_top","","true");
    win.opener = true; 
    win.close();
}
}

function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.top.location.href.slice(window.top.location.href.indexOf('?') + 1).split('&');
   
for (var i = 0; i < hashes.length; i++)
    {
        hash = hashes.split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 22, 2015 Jan 22, 2015

I tried both but it didn't work. Wondering if changes to the Captivate html file are correct.

<!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">

<!-- Copyright [2012] Adobe Systems Incorporated.  All rights reserved -->

<html lang="en">

  <head>

       <link rel="stylesheet" type="text/css" href="captivate.css" />

       <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

       <title>FRA 218 - Engineering</title>

       <!-- Include external JS files -->

       <script language="JavaScript1.2" src="standard.js" ></script>

       <script language="JavaScript1.2" src="scormdriver.js" ></script>

       <script language="JavaScript1.2" src="SCORM_utilities.js" ></script>

       <script language="JavaScript1.2" src="Utilities.js" ></script>

       <script language="JavaScript1.2">

       //Register event handlers

       window.onkeypress   = CheckForDebugCommand;

       window.onload = OnloadActivities;

       window.onbeforeunload = DoFinish;

       window.onunload = DoFinish;

       blnDebug = false ;

  </script>

</head>

  <body bgcolor="#f5f4f1" onUnload="window.opener.location.reload();">

       OR

<body bgcolor="#f5f4f1" onUnload="window.opener.location.href = window.opener.location.href;">

          <div id = "CaptivateContent">

            <noscript>

                 This course requires JavaScript to be enabled in your browser.

                 Please enable JavaScript, then relaunch the course.

            </noscript>

       </div>

  </body>

</html>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 22, 2015 Jan 22, 2015
LATEST

I'll try and test it in the SCORM Cloud since it opens in a new window and see what I can come up with. Probably sometime this weekend.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources