我有一个小程序和一个 JavaScript 函数。小程序正在调用 JavaScript 函数。我已将小程序保存为 .class 并且我已经在小程序标记中给出了位置。当我加载网页并单击按钮时调用 JavaScript 函数并触发它向小程序发送数据,网页永远冻结。我能做些什么来克服这个问题?这是网页上的小程序标签。
Here is javascript function which sends data to applet
function PrintReceipt(myApp)
{
var totalElem=document.getElementById("total");
var taxElem=document.getElementById("tax");
//var changeElem=document.getElementById("change");
//var subtotalElem=document.getElementById("subtotal");
//var discountElem=document.getElementById("discount");
//var salesitemsElem=document.getElementById("product");
var myApp = document.applets['jposprint'];
myApp.ReceiveData(taxElem.innerHTML + totalElem.innerHTML);
alert("js k.");
}
Here is the applet code which receives the data.
public void ReceiveData(String DataFromJS,Graphics g)
{
JSObject window=JSObject.getWindow(this);
window.call("PrintReceipt()", new Object[] {DataFromJS}) ;
System.out.print(DataFromJS);
//System.out.println(DataFromJS);
//return DataFromJS;
// g.setColor(Color.black);
//Total=(int)window.eval("PrintReceipt()");
//UserName=(String)window.eval("PrintReceipt()");
}
}
Regards Masiela.