呼叫Applet.getMethod()的JavaScript会抛出错误信息:类型错误:Applet.getMethod()不是一个函数 [英] Call Applet.getMethod() with javascript throws error msg : TypeError: Applet.getMethod() is not a function

查看:298
本文介绍了呼叫Applet.getMethod()的JavaScript会抛出错误信息:类型错误:Applet.getMethod()不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用JMF库的小程序,被称为是这样的:

I have an applet that use JMF libraries, called like this :

<object id="cameraViewer"
    classid="java:MyApplet.class"
    type="application/x-java-applet"
    archive="myapplet.jar" height="197" width="159"
    align="middle" codebase=".">
    <param name="code"
        value="MyApplet" />
    <param NAME="MAYSCRIPT" VALUE="true" />
    <param name="appletWidth" value="250" />
    <param name="appletHeight" value="200" />
    <param name="archive" value="myapplet.jar" />
    <param name="JAVA_CODEBASE" value="." />
    <font color="red">Applet error</font>
</object>

然后调用javascript功能:

then I call a javascript function :

var cameraViewer = document.getElementById('cameraViewer');
var deviceList = new Array(cameraViewer.listDevices());

在JavaScript的code的第二行,抛出一个错误在JavaScript控制台(类型错误:cameraViewer.listDevices不是一个函数)。

In the second line of javascript code, an error is thrown in javascript console (TypeError: cameraViewer.listDevices is not a function).

当我使用Windows 7与Firefox 8.0.1这个问题只抛出

this problem is thrown only when I use Windows 7 with Firefox 8.0.1

由于此code工作正常:

Because this code works fine with :


  • Windows 7和Chrome浏览器

  • 的Windows 7和Firefox 20

  • 的Windows XP和Firefox 8.0.1

你有任何想法,对这个问题!?

Have you any Idea about this problem !!?

推荐答案

我觉得你是想叫,而它仍然尚未加载的功能(浏览器differentely行为上的小程序加载,一些负载它同步,而其他没有)

i think you are trying to call the function whilst it's still not loaded yet (browsers behave differentely on applet loading, some load it synchronously while other don't).

这将是更安全的为您检查是否试图调用它之前就存在的功能,如果它不,告诉浏览器等待几毫秒的。

it would be safer for you to check if the function exists before trying to call it , in case it doesn't , tell the browser to wait a few milli seconds .

这里有一个模拟code你:

here's a mock code for you:

    var cameraViewer = document.getElementById('cameraViewer');

    if (typeof(cameraViewer.listDevices) != "undefined") { 
    // safe to use the function
    var deviceList = new Array(cameraViewer.listDevices());
}
else{
  setTimeout(function() {
    var deviceList = new Array(cameraViewer.listDevices());
  }, 1000);
}

这篇关于呼叫Applet.getMethod()的JavaScript会抛出错误信息:类型错误:Applet.getMethod()不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆