Side navigation
#2349 closed bug (fixed)
Opened February 15, 2008 12:38PM UTC
Closed December 07, 2009 04:02AM UTC
Script error leaving page with applet tag (related to #1675?)
Reported by: | JesperSJensen | Owned by: | flesler |
---|---|---|---|
Priority: | major | Milestone: | 1.4 |
Component: | data | Version: | 1.4a1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
A new ticket created! Also in comment to #1675!
Applet tag (and script) on html gives script error
I have problem in firefox version 2.0.0.12. 'xx.xxx.xxxx.class has no public field or method named "JQuery....' Error introduced AFTER 1.2.1! Problem introduced in 1.2.2 (and still in 1.2.3).
No problem in ie7.0.
My html produce a valid html document with a applet tag. And everything works fine with jquery 1.2.1. Error is when leaving page (cleanup cache?) My html:
... <div class="applet">
<script type="text/javascript">
/*<![CDATA[*/writeApplet('appletId','xx.xxx.xxxx.class','appletName','600','350','xxx.jar','/','MAYSCRIPT',{'archive':'xxx.jar','Cabbase':'xxx.cab','agent':+navigator.userAgent+});/*]]>*/
</script>
<script type="text/javascript">
/*<![CDATA[*/document.write('<\\/applet>')/*]]>*/
</script>
</div>
In jquery 1.2.3 (developer version) error is in line 674 (it seems to be when cleaning cache for elem = script!).
// Compute a unique ID for the element
673 if ( !id )
674 id = elem[ expando ] = ++uuid;
675
regards,
Attachments (0)
Change History (12)
Changed April 03, 2008 02:27PM UTC by comment:1
Changed April 03, 2008 02:50PM UTC by comment:2
After some more research, this appears to be related to problems with applet and object tags (which contain Java applets) when trying to write expando properties in Firefox v2.x.
If I change the data() method to:
data: function( elem, name, data ) {
elem = elem == window ?
windowData :
elem;
if( !!elem.tagName && (elem.tagName.toLowerCase() == "applet" || elem.tagName.toLowerCase() == "object") ) return false;
var id = elem[ expando ];
Compute a unique ID for the element
if ( !id )
id = elem[ expando ] = ++uuid;
Only generate the data cache if we're
trying to access or manipulate it
if ( name && !jQuery.cache[ id ] )
jQuery.cache[ id ] = {};
Prevent overriding the named cache with undefined values
if ( data != undefined )
jQuery.cache[ id ][ name ] = data;
// Return the named cache data, or the ID for the element
return name ?
jQuery.cache[ id ][ name ] :
id;
},
This fixes the problem. However, I don't think this is a proper fix for the issue as there are other functons that try to access the expando object.
Changed April 29, 2008 04:46PM UTC by comment:3
Same problem with Applets and JQuery when unloading.
I have a test page with this bug that also crashes IE7, stopping the unloading and forcing me to terminate the IExplorer process. To reproduce the error i've taken the example from Dan Switzer and modified the div and the applet tag:
... <div style="display: none;"> <object id='applet' classid='clsid:8AD9C840-044E-11D1-B3E9-00805F499D93' codebase='https://java.sun.com/products/plugin/autodl/jinstall-1_4-windows-i586.cab#Version=1,4,0,0' width='150' height='50' mayscript='true'> <param name='type' value='application/x-java-applet;version=1.4'> <param name='code' value='HelloWorld.class'> <param name='archive' value='./'> <param name='mayscript' value='true'> <param name='scriptable' value='true'> </object> </div> ...
If I remove the display:none works fine on IE7. It also works when using the applet tag instead of the object tag.
We don't use jQuery to modify anything on the applets so we have changed the following lines in jquery (1.2.3):
// 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(); });
... to this ...
// 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("*:not(object):not(embed):not(applet)").add(document).unbind(); });
... so we don't have errors in IE and FF.
Changed June 15, 2008 10:04PM UTC by comment:4
I've been trying like every workaround I could find on the net, but the Java Applet "Jumploader" 2.8.5 (see http://www.jumploader.com/) throws errors with jQuery 1.2.6 in Firefox 2.0.0.14:
Java class jmaster.jumploader.app.JumpLoaderApplet has no public field or method named "jQuery1213566312578" var id = elem[ expando ]; jquery-1.2.6.js (line 662) Java class jmaster.jumploader.app.JumpLoaderApplet has no public field or method named "jQuery1213566312578" id = elem[ expando ] = ++uuid; jquery-1.2.6.js (line 666)
This happens randomly while loading or (for example) after hiding the applet container with .hide(). If this is really supposed to be "fixed" (#1675) then I wanna know what to do about it (other than waiting and pray to god *lol*).
If I apply to workaround mentioned above, I get:
Java class jmaster.jumploader.app.JumpLoaderApplet has no public field or method named "onajaxSuccess" if ( (!fn || (jQuery.nodeName(elem, 'a') && type == "click")) && elem["on"+ty... jquery-1.2.6.js (line 2022)
This is not much better ^^ Any hints? Other things to try?
Changed October 23, 2008 01:57AM UTC by comment:5
Indeed, this has stumped me for a couple of hours, because I wanted to implement a solution that didn't involve having to hack the jQuery source.
This is not just an issue for the unload event, it just so happens the unload event is what commonly manifests this error because it guaranteed to be triggered for applet/object/embed tags that are host to Java Applets. As a result the code fixes above don't really fix the root of the issue.
Here's my solution to the problem: (I haven't put in a patch attachment for now, I'll let others review the code below first)
Place this below the nodeName function:
isExternal: function(elem) { return (jQuery.nodeName(elem, 'embed') || jQuery.nodeName(elem, 'object') || jQuery.nodeName(elem, 'applet')); }, isHtmlElement: function(elem) { return !(elem.nodeType == 3 || elem.nodeType == 8 || jQuery.isExternal(elem)); },
Then replace all bits of code where:
elem.nodeType == 3 || elem.nodeType == 8
occur (about 4 times, mainly in the events section inside 'if' conditionals) with:
! jQuery.isHtmlElement(elem)
This fix is good enough for most people, however I will admit that my isExternal() implementation leaves a little to be desired for detecting Applets. (I originally called this isApplet, but Flash, and a few other external plugins use object/embed). Object tags are supposed replace img tags in XHTML 2, therefore one probably is best to sniff the MIME/content type of the object tag to ensure it's a java applet, or flash object etc (I'm not sure if flash is giving the same issues as Java here)
Changed October 23, 2008 02:07AM UTC by comment:6
Also, I forgot to say my work around manages to work in the situation where you are removing / modifying HTML that hosts a Java Applet through an AJAX request.
(Without my work I had issues in MSIE where I got JS errors when an AJAX request replaced the object/embed code with something else. This was failing because the replace process would need to transverse the Applet nodes when removing them via methods such as remove/empty/html)
Changed October 30, 2008 01:05AM UTC by comment:7
milestone: | 1.2.4 → 1.3 |
---|---|
need: | Review → Patch |
owner: | → flesler |
status: | new → assigned |
Changed October 31, 2008 07:05PM UTC by comment:8
Another demo page can be found here:
http://malsup.com/jquery/test/applet.html
MiiJaySung's suggestions do seem to fix the problem.
Changed October 31, 2008 08:42PM UTC by comment:9
That approach is really lengthy. I don't think we need such checks.
Just avoiding to set the expando for these 3 would do. The thing is, what do we use to generate a uid.
Maybe using the id/name attribute if existent, and setting a new one if none is used.
Changed November 11, 2008 07:11AM UTC by comment:10
I'm also experiencing this bug, with an FTP java applet that i must use to enable large uploads for my CMS.
I modified 1.2.6-source so that it no longer generates warnings.
It's a very crude hack, but i want to share it with you anyway..
http://82.170.249.144/mediaBeez/lib/jquery/jquery-1.2.6.source_VIS.js
Changed April 02, 2009 12:40AM UTC by comment:11
I had the same problem (IE7) with 1.2.3 when exiting the page but could not modify the jQuery source in my environment. I added the following code to my javascript to cancel the regular jQuery unload event and replace it with the one suggested by serhii.
jQuery(window).unbind("unload"); jQuery(window).bind("unload", function() { jQuery("*:not(object):not(embed):not(applet)").add(document).unbind();});
Changed December 07, 2009 04:02AM UTC by comment:12
component: | core → data |
---|---|
milestone: | 1.3 → 1.4 |
resolution: | → fixed |
status: | assigned → closed |
version: | 1.2.3 → 1.4a1 |
I'm seeing this exact same issue, but I also get an error as soon as you try to hide an applet as well. I've set up an example at:
http://www.pengoworks.com/workshop/jquery/bug_applet/jquery_applet_bug.htm
On the first page load, it'll work correctly. When you reload you'll get an error.