在FireFox Java错误 - myApplet.myFunction不是一个函数 [英] Java error in FireFox - myApplet.myFunction is not a function

查看:164
本文介绍了在FireFox Java错误 - myApplet.myFunction不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到一个错误,这只是在Firefox中重现的。

在IE中,它始终工作。

我有一个目标一个小程序的ASP.NET应用程序。对于大多数的功能,它的伟大工程,但是当我运行一个函数(即做了很多不同的东西一个功能),似乎在Java Applet的方法不可用!当我呼吁从Javascript code中的Java小程序的功能,我得到的错误: myApplet.myFunction不是一个函数

在这个已经发生了,我得到同样的错误在此之前状态的工作一切在小程序调用的函数,也是功能。

小程序不会被卸载或崩溃,这是由在applet的互动功能仍然有效证明。但是,如果小程序调用回调到小程序在页面上的JavaScript函数,我得到了同样的错误!

有时,它的工作原理,当我重复动作多次。

这只是发生在公版的Web应用程序。不要在开发机器上运行我的本地web应用程序。主要的区别是,公众使用一次登录访问。

谁能给我什么可以导致此暗示?

要summairize发生了什么:当我运行JavaScript code的特定位,对Java小程序的API变得unabailable(错误: myApplet.myFunction不是一个函数

下面是导致小程序的这个越野车状态功能:

 函数ParseAndZoomToAddress(objString){
 VAR mapFrame 的eval(VAR objArray =新的Array(+ objString +))
 如果(objArray.length大于0){
  mapFrame = window.frames [0] .frames ['mapFrame']
  如果(!mapFrame)警报('mapFrame为空!)
  否则对window.status ='mapFrame是OK!
  VAR center_x = 0
  VAR center_y = 0
  如果(objArray.length == 1){
   VAR rExp1 = / [G-P] / G
   VAR rExp2 = / [Q-Z] / G
   的eval(VAR coordArray =新的Array(+ objArray [0] .replace(rExp1,0X)取代(rExp2,'0X')+))
   如果(coordArray.length == 2){
    center_x = coordArray [0]
    center_y = coordArray [1]
   }其他{
    警报(无效的ID+ objArray [0])
   }
  }其他{
   变种center_x = objArray [1]
   变种center_y = objArray [2]
  }
  VAR objZoomScale ='2000'// document.SearchForm.Scale.value
  VAR规模= mapFrame.m_yur - mapFrame.m_yll
  如果(objZoomScale!=){
   规模= ScaleToMeter(parseInt函数(objZoomScale),mapFrame.m_image_width)
  }
  VAR XLL = center_x - (刻度/ 2.0)
  VAR基] - = center_y - 10
  VAR xur = XLL +规模
  VAR尤尔= center_y + 10
  center_x =(XLL + xur)/ 2.0
  center_y =(+基] - 尤尔)/ 2.0
  center_x = Math.round(center_x * 1000)/ 1000
  center_y = Math.round(center_y * 1000)/ 1000
  mapFrame.ResetClipPolygon()//调用此方法的applet
  变种lCenterSymbol ='5024,40,85,X,Y,5'
  VAR rExp = / X / GI
  lCenterSymbol = lCenterSymbol.replace(rExp,center_x)
  rExp = / Y / GI
  lCenterSymbol = lCenterSymbol.replace(rExp,center_y)
  mapFrame.parent.m_CenterSymbolString = lCenterSymbol
  mapFrame.ResetClipPolygon()//调用此方法的applet
  mapFrame。previewVisible()
  mapFrame.mapVisible()
  mapFrame.setMove(假)//调用此方法的applet
  mapFrame.ZoomToArea(XLL,基],xur,尤尔)//调用此方法的applet
  mapFrame.parent.m_CenterSymbolString =
 }
}

Additionaly我可以说,小程序是由中所定义;小程序> 标记。

该小程序位于在< D​​IV> 是隐藏在JavaScript与的style.display ='无'标记的style.display =块再次显示
这是在2号线完成:

  mapFrame。previewVisible()
  mapFrame.mapVisible()

我不知道这是否是问题,但这些功能被称为别处,以及在那里它不会导致此,但也可能是对事物的组合。

我很高兴能得到暗示的,这将帮助我解决这个,而不是绝对的解决方案。

我都会接受最好的提示,答案。


解决方案

也许这是一个时机的问题。它可能发生的火狐引擎尝试执行JavaScript code中的Java小程序已正确加载之前。为了验证这一点在JavaScript code访问小程序前添加延迟。更妙的是使用try-catch块您的来电,并在for循环包裹。如果调用成功退出循环,否则增加一个延迟和重试。

编辑:根据您的修改似乎没有一个时机的问题。由于您的javascript函数是相当大的,我会尝试找到,哪里出了问题首先出现。创建一个虚拟的小程序方法,并在不同的地方把它叫做你的JavaScript方法内。了解之后,语句首先出现的问题。另外,如果你还没有做到这一点已经安装萤火虫并观看了JavaScript错误。

I am getting an error that is only reproducible in Firefox.
In IE, it always works.

I have an ASP.NET application that targets an applet. For most functionality, it works great, but when I run one function (a function that does a lot of different things), the methods on the java applet seems to be unavailable! When I call any functions on the java applet from Javascript code, I get the error : myApplet.myFunction is not a function .

After this has happened, I get the same error for everything that calls functions on the applet, also functionality that worked prior to this state.

The applet is not unloaded or crashed, which is proved by that the interactive functions in the applet still works. But if the applet calls a javascript function on the page that calls back to the applet, I get the same error!

Sometimes it works when I repeat the action several times.

This only happens on the public version of the web application. Not in my local web app that runs on development machine. The main difference is that the public one use login access.

Can anyone give me hint of what can be causing this?

To summairize whats happens: When I run a particular bit of javascript code, the API against the java applet becomes unabailable (Error: myApplet.myFunction is not a function).

Here is the function that causes this buggy state of the applet:

function ParseAndZoomToAddress (objString) {
 var mapFrame

 eval("var objArray = new Array(" + objString + ")")
 if (objArray.length > 0) {
  mapFrame = window.frames[0].frames['mapFrame']
  if(!mapFrame) alert('mapFrame is null!')
  else window.status = 'mapFrame is OK!'
  var center_x = 0
  var center_y = 0
  if(objArray.length == 1) {
   var rExp1 = /[G-P]/g
   var rExp2 = /[Q-Z]/g
   eval("var coordArray = new Array(" + objArray[0].replace(rExp1, '0x').replace(rExp2, ',0x') + ")")
   if(coordArray.length == 2){
    center_x = coordArray[0]
    center_y = coordArray[1]
   }else{
    alert("Invalid ID " + objArray[0])
   }
  }else{
   var center_x = objArray[1]
   var center_y = objArray[2]
  }
  var objZoomScale = '2000' // document.SearchForm.Scale.value
  var scale = mapFrame.m_yur - mapFrame.m_yll
  if (objZoomScale != "") {
   scale = ScaleToMeter(parseInt(objZoomScale),mapFrame.m_image_width)
  }
  var xll = center_x - (scale / 2.0)
  var yll = center_y - 10
  var xur = xll + scale
  var yur = center_y + 10
  center_x = (xll + xur) / 2.0
  center_y = (yll + yur) / 2.0
  center_x = Math.round(center_x * 1000) / 1000
  center_y = Math.round(center_y * 1000) / 1000
  mapFrame.ResetClipPolygon() //This calls applet methods
  var lCenterSymbol = '5024,40,85,x,y,5'
  var rExp = /x/gi
  lCenterSymbol = lCenterSymbol.replace(rExp,center_x)
  rExp = /y/gi
  lCenterSymbol = lCenterSymbol.replace(rExp,center_y)
  mapFrame.parent.m_CenterSymbolString = lCenterSymbol
  mapFrame.ResetClipPolygon() //This calls applet methods
  mapFrame.previewVisible()
  mapFrame.mapVisible()
  mapFrame.setMove(false) //This calls applet methods
  mapFrame.ZoomToArea(xll, yll, xur, yur) //This calls applet methods
  mapFrame.parent.m_CenterSymbolString = ""
 }
}

Additionaly I can say that the applet is defined by the <applet> tag.

The applet is located inside a <div> tag that is hidden in javascript with style.display='none' and shown again with style.display='block'. This is done during the 2 lines:

  mapFrame.previewVisible()
  mapFrame.mapVisible()

I don't know if this is the problem, but these function are called elsewhere as well where it doesn't cause this, but it might be combination of things.

I am happy to get hint's that will help me solve this, not an absolute solution.

I will accept the best hint as the answer.

解决方案

Perhaps this is a timing issue. It could happen that the Firefox engine tries to execute the javascript code before the java applet has been properly loaded. To verify this add a delay before accessing the applet in javascript code. Even better use a try-catch block for your call and wrap it in a for-loop. If the call is successful exit the loop, otherwise add a delay and retry.

Edit: Based on your edits it seems that there isn't a timing issue. Since your javascript function is quite big, I would try to locate, where the problem first appears. Create a dummy applet method and call it inside your javascript method at various places. Find out after which statement the problem first appears. Also, if you haven't done that already, install Firebug and watch out for javascript errors.

这篇关于在FireFox Java错误 - myApplet.myFunction不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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