469,646 Members | 1,623 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,646 developers. It's quick & easy.

SCORM LMS API and Javascript

Hello, I have an applet named API and the code that calls it, in a JSP, is :
<applet code="API" archive="lms.jar" height="0" width="0" >If you see this
message, your browser cannot run Applet LMS.</applet>

The page has also a JavaScript code that looks as:

function findAPI(win)
{
while ((win.API == null) && (win.parent != null) && (win.parent != win))
{
findAPITries++;
// Note: 7 is an arbitrary number, but should be more than sufficient
if (findAPITries 7)
{
alert("Error finding API -- too deeply nested.");
return null;
}

win = win.parent;

}
return win.API;
}

From Java console I see the applet loaded and inited, but the function above
returns "null". It seems that the applet is loaded but the Javascript cannot
see it.
Can you help me?
The environment is: Tomcat, Java, Eclipse, Windows/Linux.

Thank you.
Nov 26 '06 #1
4 9375
Birbo wrote:
Hello, I have an applet named API and the code that calls it, in a JSP, is :
<applet code="API" archive="lms.jar" height="0" width="0" >
It seems that the applet is loaded but the Javascript cannot
see it.
If you have just one applet then you can access
document.applets[0]
in JavaScript to access the applet.
Or give the applet a name attribute e.g.
<applet name="appletName" ...>
and then you can access
document.applets.appletName
You can also give the applet an id attribute
<applet id="appletId" ...>
and then you can use
document.getElementById('appletId')
in script to access the applet.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 26 '06 #2

"Martin Honnen" <ma*******@yahoo.deha scritto nel messaggio
news:45***********************@newsspool4.arcor-online.net...
>>It seems that the applet is loaded but the Javascript cannot
see it.

If you have just one applet then you can access
document.applets[0]
in JavaScript to access the applet.
Or give the applet a name attribute e.g.
<applet name="appletName" ...>
and then you can access
document.applets.appletName
You can also give the applet an id attribute
<applet id="appletId" ...>
and then you can use
document.getElementById('appletId')
in script to access the applet.
Thank you for your answer. The problem is that the javascript is not mine,
it is part of a package I have only to run into my platform. I have to write
the applet that exposes the functions called by the javascript. Furthermore,
the same packet works fine on other platforms (most of them are in php).
Inspecting the source:

function findAPI(win)
{
while ((win.API == null) && (win.parent != null) && (win.parent != win))
{
...
}
return win.API;
}

I guess it expects an object name "API" belonging to win. Maybe I am missing
some init function as:

var API = document.getElementById('appletId');

Tomorrow I'll try this way.
Nov 26 '06 #3
Birbo wrote:
Hello, I have an applet named API and the code that calls it, in a JSP, is :
<applet code="API" archive="lms.jar" height="0" width="0" >If you see this
message, your browser cannot run Applet LMS.</applet>

The page has also a JavaScript code that looks as:

function findAPI(win)
{
while ((win.API == null) && (win.parent != null) && (win.parent != win))
{
findAPITries++;
// Note: 7 is an arbitrary number, but should be more than sufficient
if (findAPITries 7)
{
alert("Error finding API -- too deeply nested.");
return null;
}

win = win.parent;

}
return win.API;
}

From Java console I see the applet loaded and inited, but the function above
returns "null". It seems that the applet is loaded but the Javascript cannot
see it.
Can you help me?
The environment is: Tomcat, Java, Eclipse, Windows/Linux.
That code is for SCORM 1.2 and it looks like the sample code from
adl.org which has "errors" in it.

Show the rest of the javascript.

Andrew Poulos
Nov 26 '06 #4

"Andrew Poulos" <ap*****@hotmail.comha scritto nel messaggio
news:45***********************@per-qv1-newsreader-01.iinet.net.au...
>
That code is for SCORM 1.2 and it looks like the sample code from adl.org
which has "errors" in it.
Thanks, I solved the problem using the following code:

<applet code="API" archive="${initParam.projectPath }/assets/lms/lms.jar"
id="APIApplet" codebase="${initParam.projectPath }/assets/lms"
MAYSCRIPT="true" height="0" width="0" >
If you see this message, your browser cannot run Applet LMS.</applet>

<script type="text/javascript">
window.onload = function()
{
API = this.document.APIApplet;
}
</script>
Nov 27 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.