更新时间:2023-11-19 20:15:40
对于第一个问题,怎么样努力
警报($(#小程序-ID)[0]包含.foo());
对于这里的第二个问题是href=\"http://groups.google.com/group/jquery-dev/browse_thread/thread/c67483e58caacbfd\">一个可能的解决方法线程一个 引用的解决办法
在IE
// prevent内存泄漏
//而且prevent刷新上像在其他浏览器的鼠标悬停事件的错误
//不包括窗口,以便不解除现有卸载事件
jQuery的(窗口).bind(卸载,
功能(){
jQuery的(*)加(文件).unbind()。
});
块引用>
更改code为:
//窗口不包括以免解除现有的卸载事件
jQuery的(窗口).bind(卸载,
功能(){
jQuery的(*:不是('小程序,对象'))增加(文件).unbind();
});
块引用>I'm working on a project where we're using a Java applet for part of the UI (a map, specifically), but building the rest of the UI around the applet in HTML/JavaScript, communicating with the applet through LiveConnect/NPAPI. A little bizarre, I know, but let's presume that setup is not under discussion. I started out planning on using jQuery as my JavaScript framework, but I've run into two issues.
Issue the first:
Selecting the applet doesn't provide access to the applet's methods.
Java:
public class MyApplet extends JApplet { // ... public String foo() { return "foo!"; } }
JavaScript:
var applet = $("#applet-id"); alert(applet.foo());
Running the above JavaScript results in
$("#applet-id").foo is not a functionThis is in contrast to Prototype, where the analogous code does work:
var applet = $("applet-id"); alert(applet.foo());
So...where'd the applet methods go?
Issue the second:
There's a known problem with jQuery and applets in Firefox 2: http://www.pengoworks.com/workshop/jquery/bug_applet/jquery_applet_bug.htm
It's a long shot, but does anybody know of a workaround? I suspect this problem isn't fixable, which will mean switching to Prototype.
Thanks for the help!
For the first issue, how about trying
alert( $("#applet-id")[0].foo() );
For the second issue here is a thread with a possible workaround.
Quoting the workaround
// Prevent memory leaks in IE // And prevent errors on refresh with events like mouseover in other browsers // Window isn't included so as not to unbind existing unload events jQuery(window).bind("unload", function() { jQuery("*").add(document).unbind(); });
change that code to:
// Window isn't included so as not to unbind existing unload events jQuery(window).bind("unload", function() { jQuery("*:not('applet, object')").add(document).unbind(); });