Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    building a js api, having browser problems

    Hello,

    I'm trying to build a simple API - it's running fine in Safari and Firefox but failing in IE and Opera. In order to isolate the problem I've stripped it right back 'til all the methods are just alerting their own name. Safari and Firefox give me loads of alerts, but in Opera and IE I just get one, LMSInitialize() when the page first loads - at least I know the browser is finding the API properly.

    IE also runs LMSCommit() and LMSFinish() when you close the browser window; that's good, but not enough. Opera doesn't even do that. The trigger for all this is a Flash movie created in Adobe Captivate, and published with a whole lot of its own JS which I can't touch - it's running in an iframe, and it's the parent window which includes the API. I need to work out whether there's an issue in my code, or if it's to do with the movie or the publication settings - that side of things is out of my control.

    Here's the full code of my test version of the API. I'd really appreciate any comments!

    Thanks,
    Ben

    Code:
    function SIScormAPI(){
    	this.version = '1.2';
    
    	this.LMSInitialize = LMSInitialize;
    	this.LMSFinish = LMSFinish;
    	this.LMSGetValue = LMSGetValue;
    	this.LMSSetValue = LMSSetValue;
    	this.LMSCommit = LMSCommit;
    	this.LMSGetLastError = LMSGetLastError;
    	this.LMSGetErrorString = LMSGetErrorString;
    	this.LMSGetDiagnostic = LMSGetDiagnostic;
    }
    
    function LMSInitialize(){
    
    	var alertStr1 = 'LMSInitialize() - v.'+this.version;
    	alert(alertStr1);
    }
    
    function LMSFinish(){
    
    	var alertStr2 = 'LMSFinish()';
    	alert(alertStr2);
    }
    
    function LMSGetValue(){
    
    	var alertStr3 = 'LMSGetValue()';
    	alert(alertStr3);
    }
    
    function LMSSetValue(){
    
    	var alertStr4 = 'LMSSetValue()';
    	alert(alertStr4);
    }
    
    function LMSCommit(){
    
    	var alertStr5 = 'LMSCommit()!!!!!';
    	alert(alertStr5);
    }
    
    function LMSGetLastError(){
    
    	var alertStr6 = 'LMSGetLastError()';
    	alert(alertStr6);
    }
    
    function LMSGetErrorString(){
    
    	var alertStr7 = 'LMSGetErrorString()';
    	alert(alertStr7);
    }
    
    function LMSGetDiagnostic(){
    
    	var alertStr8 = 'LMSGetDiagnostic()';
    	alert(alertStr8);
    }
    
    API = new SIScormAPI();

  • #2
    New to the CF scene
    Join Date
    Aug 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've been working on this, of course, and substantially re-written the code after testing it in an on-line validator. Now it's started working in IE8 but stopped in Firefox, still working in Safari, failing in Chrome on a Mac but partly working (i.e. I'm seeing some alerts but not others) in Chrome in Windows... so that proves the error is in my code, somewhere, although it passes a fairly strict on-line validator. The 'increment' variable is just my own versioning so I can make sure that I'm not seeing results from a cached version of the API. Here's the new code in full:

    Code:
    var mySIScormAlertStr = '';
    function LMSInitialize() {
    	mySIScormAlertStr = 'LMSInitialize() - ' + this.increment;
    	alert(mySIScormAlertStr);
    	return true;
    }
    function LMSFinish() {
    	mySIScormAlertStr = 'LMSFinish() - ' + this.increment;
    	alert(mySIScormAlertStr);
    	return true;
    }
    function LMSGetValue(varName) {
    	mySIScormAlertStr = 'LMSGetValue() - ' + this.increment + '\nvarName\t' + varName;
    	alert(mySIScormAlertStr);
    	return true;
    }
    function LMSSetValue(varName, varValue) {
    	mySIScormAlertStr = 'LMSSetValue() - ' + this.increment + '\nvarName\t' + varName + '\nvarValue\t' + varValue;
    	alert(mySIScormAlertStr);
    	return true;
    }
    function LMSCommit() {
    	mySIScormAlertStr = 'LMSCommit() - ' + this.increment;
    	alert(mySIScormAlertStr);
    	return true;
    }
    function LMSGetLastError() {
    	mySIScormAlertStr = 'LMSGetLastError() - ' + this.increment;
    	alert(mySIScormAlertStr);
    	return true;
    }
    function LMSGetErrorString() {
    	mySIScormAlertStr = 'LMSGetErrorString() - ' + this.increment;
    	alert(mySIScormAlertStr);
    	return true;
    }
    function LMSGetDiagnostic() {
    	mySIScormAlertStr = 'LMSGetDiagnostic() - ' + this.increment;
    	alert(mySIScormAlertStr);
    	return true;
    }
    function SIScormAPI() {
    	this.version = '1.2';
    	this.increment = '23';
    	this.error = '0';
    	this.initialized = false;
    	this.keepValues = {};
    
    	this.LMSInitialize = LMSInitialize;
    	this.LMSFinish = LMSFinish;
    	this.LMSGetValue = LMSGetValue;
    	this.LMSSetValue = LMSSetValue;
    	this.LMSCommit = LMSCommit;
    	this.LMSGetLastError = LMSGetLastError;
    	this.LMSGetErrorString = LMSGetErrorString;
    	this.LMSGetDiagnostic = LMSGetDiagnostic;
    }
    var API = new SIScormAPI();
    Thanks to everybody who's reading this - I'd be really grateful for any kind of hint as to why it's working on some browsers and not others!

    Cheers,
    Ben


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •